Skip to content

Commit

Permalink
fix: [GSW-2040] Improve ConnectError modal Appear
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrg committed Jan 17, 2025
1 parent 1885a0b commit 1c59864
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/web/src/hooks/common/use-background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const useBackground = () => {
useEffect(() => {
if (walletClient) return;

const MAX_RETRY = 5;
const RETRY_INTERVAL = 200;
const MAX_RETRY = 1;
const RETRY_INTERVAL = 1000;

const initWalletBySession = async () => {
const savedWalletType = sessionStorage.getItem(GNOSWAP_WALLET_TYPE_KEY);
Expand All @@ -127,7 +127,7 @@ export const useBackground = () => {
let count = 0;

return () => clearInterval(retryInterval);
}, [walletClient, sessionId, initSession]);
}, [walletClient?.getWalletType(), sessionId, initSession]);

/**
*
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/hooks/wallet/data/use-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export const useWallet = () => {
}, [setNetwork, walletAccount]);

const disconnectWallet = useCallback(() => {
disconnect();
setWalletClient(null);
setWalletAccount(null);
setSessionId("");
Expand All @@ -114,6 +113,7 @@ export const useWallet = () => {
sessionStorage.removeItem(GNOSWAP_SOCIAL_LOGIN_TYPE_KEY);
accountRepository.setConnectedWallet(false);
setLoadingConnect("initial");
disconnect();
}, [accountRepository]);

async function initSession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,11 @@ export const SocialWalletProvider = ({ children }: { children: React.ReactNode }
} else {
accountRepository.setConnectedWallet(false);
setConnectingState("error");
openConnectErrorModal();
resetConnectingState();
}
} catch (err) {
resetSocialWalletState();
setConnectingState("error");
openConnectErrorModal();
setError(err instanceof Error ? err.message : "Failed to connect Social Wallet");
}
};
Expand All @@ -135,8 +133,7 @@ export const SocialWalletProvider = ({ children }: { children: React.ReactNode }
} catch (err) {
resetSocialWalletState();
setConnectingState("error");
openConnectErrorModal();
setError(err instanceof Error ? err.message : "Connection timeout");
setError(err instanceof Error ? err.message : "Failed to connect Social Wallet");
}
};

Expand Down

0 comments on commit 1c59864

Please sign in to comment.