From 1a3918b8d0673aee24da5068efaaf04f36e50fde Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 17:37:53 +0700 Subject: [PATCH] fix ux session expired --- src/components/Header/web3/SignWallet/ProfileContent.tsx | 7 ++++++- src/hooks/useSessionExpire.ts | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/Header/web3/SignWallet/ProfileContent.tsx b/src/components/Header/web3/SignWallet/ProfileContent.tsx index 20824faf12..5514030ad2 100644 --- a/src/components/Header/web3/SignWallet/ProfileContent.tsx +++ b/src/components/Header/web3/SignWallet/ProfileContent.tsx @@ -226,7 +226,12 @@ const ProfileContent = ({ scroll, toggleModal }: { scroll?: boolean; toggleModal 1}> {!KyberOauth2.getConnectedAccounts().includes(account?.toLowerCase() ?? '') && isEVM && ( - signIn()}> + { + toggleModal() + signIn() + }} + > Add Account )} diff --git a/src/hooks/useSessionExpire.ts b/src/hooks/useSessionExpire.ts index 63f7ec24ea..82e8faa1c9 100644 --- a/src/hooks/useSessionExpire.ts +++ b/src/hooks/useSessionExpire.ts @@ -12,7 +12,7 @@ import { useSignedAccountInfo } from 'state/profile/hooks' export default function useSessionExpiredGlobal() { const { pathname } = useLocation() const showConfirm = useShowConfirm() - const { signIn, redirectSignIn } = useLogin() + const { signIn, redirectSignIn, signInAnonymous } = useLogin() const navigate = useNavigate() const { signedAccount, signedMethod } = useSignedAccountInfo() @@ -26,6 +26,9 @@ export default function useSessionExpiredGlobal() { confirmText: t`Sign-in`, cancelText: t`Cancel`, onConfirm: () => redirectSignIn(accountId || signedAccount), + onCancel: () => { + signInAnonymous(KyberOauth2.getConnectedAnonymousAccounts()[0]) + }, } const isKyberAIPage = pathname.toLowerCase().startsWith(APP_PATHS.KYBERAI.toLowerCase()) && @@ -38,7 +41,7 @@ export default function useSessionExpiredGlobal() { } KyberOauth2.on(KyberOauth2Event.SESSION_EXPIRED, listener) return () => KyberOauth2.off(KyberOauth2Event.SESSION_EXPIRED, listener) - }, [pathname, showConfirm, redirectSignIn, navigate, signedAccount]) + }, [pathname, showConfirm, redirectSignIn, navigate, signedAccount, signInAnonymous]) useEffect(() => { const listener = () => {