Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
albertfolch-redeemeum committed Mar 18, 2024
1 parent 03713cd commit 2ee4881
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export function CommitWidget(props: CommitWidgetProps) {
// @ts-ignore
[props.lookAndFeel, props.modalMargin]
);
const provider = useProvider();

return (
<Container>
<CommitWidgetProviders {...props} withReduxProvider provider={provider}>
<CommitWidgetProviders {...props} withReduxProvider>
<GlobalStyle />
<CommitModalWithOffer {...props} hideModal={props.closeWidgetClick} />
</CommitWidgetProviders>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import { useProvider } from "../../../hooks/connection/connection";
export type CommitWidgetProvidersProps = IpfsProviderProps &
Omit<ConfigProviderProps, "magicLinkKey" | "infuraKey"> &
ConvertionRateProviderProps &
Omit<WalletConnectionProviderProps, "children" | "envName"> &
Pick<UpdatersProps, "provider"> & {
Omit<WalletConnectionProviderProps, "children" | "envName"> & {
children: ReactNode;
withReduxProvider: boolean;
};
Expand Down Expand Up @@ -62,7 +61,6 @@ export const CommitWidgetReduxUpdaters = ({
export const CommitWidgetProviders: React.FC<CommitWidgetProvidersProps> = ({
children,
withReduxProvider,
provider,
...props
}) => {
const isWindowVisible = useIsWindowVisible();
Expand All @@ -82,15 +80,15 @@ export const CommitWidgetProviders: React.FC<CommitWidgetProvidersProps> = ({
const WithUpdaters = useCallback(
({ children: updatersChildren }: { children: ReactNode }) => {
return withReduxProvider ? (
<Updaters isWindowVisible={isWindowVisible} provider={provider}>
<UpdatersWrapper isWindowVisible={isWindowVisible}>
{updatersChildren}
</Updaters>
</UpdatersWrapper>
) : (
<>{updatersChildren}</>
);
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[withReduxProvider, isWindowVisible, provider]
[withReduxProvider, isWindowVisible]
);
return (
<WithReduxProvider>
Expand Down Expand Up @@ -120,3 +118,18 @@ export const CommitWidgetProviders: React.FC<CommitWidgetProvidersProps> = ({
</WithReduxProvider>
);
};

function UpdatersWrapper({
children,
isWindowVisible
}: {
children: ReactNode;
isWindowVisible: boolean;
}) {
const provider = useProvider();
return (
<Updaters isWindowVisible={isWindowVisible} provider={provider}>
{children}
</Updaters>
);
}

0 comments on commit 2ee4881

Please sign in to comment.