Skip to content

Commit

Permalink
fix ux session expired
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Jul 14, 2023
1 parent 3c092ee commit 1a3918b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/Header/web3/SignWallet/ProfileContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ const ProfileContent = ({ scroll, toggleModal }: { scroll?: boolean; toggleModal
</Column>
<ActionWrapper hasBorder={profiles.length > 1}>
{!KyberOauth2.getConnectedAccounts().includes(account?.toLowerCase() ?? '') && isEVM && (
<ActionItem onClick={() => signIn()}>
<ActionItem
onClick={() => {
toggleModal()
signIn()
}}
>
<UserPlus size={18} /> <Trans>Add Account</Trans>
</ActionItem>
)}
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useSessionExpire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()) &&
Expand All @@ -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 = () => {
Expand Down

0 comments on commit 1a3918b

Please sign in to comment.