From a52de373d164e3058981038ded044aaf00ce630f Mon Sep 17 00:00:00 2001 From: Kobe Leenders Date: Mon, 27 Nov 2023 22:59:49 +0100 Subject: [PATCH] fix: loading bugs --- .../components/common/Wallet/WalletButton.tsx | 39 ++++++++++--------- .../src/hooks/useWalletContext.tsx | 8 ++-- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/apps/marginfi-v2-ui/src/components/common/Wallet/WalletButton.tsx b/apps/marginfi-v2-ui/src/components/common/Wallet/WalletButton.tsx index 5a0091e4da..e76442830b 100644 --- a/apps/marginfi-v2-ui/src/components/common/Wallet/WalletButton.tsx +++ b/apps/marginfi-v2-ui/src/components/common/Wallet/WalletButton.tsx @@ -70,26 +70,27 @@ export const WalletButton = () => { return ( <> - {!connected ? ( - - ) : ( - - )} + {walletInfo && ( +
setIsWalletAuthDialogOpen(true)} + className="pl-2 border-l border-border inline-flex items-center" + > + +
+ )} + + + ) : ( + + ))} ); }; diff --git a/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx b/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx index a5d78e785c..ac9750bad0 100644 --- a/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx +++ b/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx @@ -205,10 +205,7 @@ const WalletProvider = ({ children }: { children: React.ReactNode }) => { // and override signTransaction methods with web3auth sdk const makeweb3AuthWalletData = React.useCallback( async (web3AuthProvider: IProvider) => { - if (!web3Auth) { - setIsLoading(false); - return; - } + if (!web3Auth) return; const solanaWallet = new SolanaWallet(web3AuthProvider); const accounts = await solanaWallet.requestAccounts(); @@ -248,7 +245,6 @@ const WalletProvider = ({ children }: { children: React.ReactNode }) => { return signedMessage; }, }); - setIsLoading(false); }, [web3Auth] ); @@ -331,6 +327,7 @@ const WalletProvider = ({ children }: { children: React.ReactNode }) => { if (!web3Auth?.connected || !web3Auth?.provider || web3AuthWalletData) return; setIsLoading(true); makeweb3AuthWalletData(web3Auth.provider); + setIsLoading(false); }, [web3Auth?.connected, web3Auth?.provider, web3AuthWalletData]); // initialize web3auth sdk on page load @@ -361,6 +358,7 @@ const WalletProvider = ({ children }: { children: React.ReactNode }) => { setweb3Auth(web3AuthInstance); } catch (error) { console.error(error); + } finally { setIsLoading(false); } };