From 00594a9861fb29c6e0004e742406bec21b49157c Mon Sep 17 00:00:00 2001 From: devinxl Date: Tue, 16 Apr 2024 11:34:47 +0800 Subject: [PATCH] fix(dcellar-web-ui): resolve issue with connect-wallet page login jump error --- .../src/context/LoginContext/useLoginGuard.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/dcellar-web-ui/src/context/LoginContext/useLoginGuard.ts b/apps/dcellar-web-ui/src/context/LoginContext/useLoginGuard.ts index 78418504..ddbcc183 100644 --- a/apps/dcellar-web-ui/src/context/LoginContext/useLoginGuard.ts +++ b/apps/dcellar-web-ui/src/context/LoginContext/useLoginGuard.ts @@ -1,5 +1,6 @@ import { InternalRoutePaths } from '@/constants/paths'; import { ssrLandingRoutes } from '@/pages/_app'; +import { useAppSelector } from '@/store'; import { useMount } from 'ahooks'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; @@ -7,7 +8,7 @@ import { useAccount } from 'wagmi'; export function useLoginGuard(inline: boolean) { const { address } = useAccount(); - + const { loginAccount } = useAppSelector((root) => root.persist); const router = useRouter(); const { pathname, asPath } = router; @@ -19,7 +20,7 @@ export function useLoginGuard(inline: boolean) { }); useEffect(() => { - if (!address) { + if (!address || !loginAccount) { if (inline) { setPass(true); } else if (pathname.length > 0 && pathname !== '/') { @@ -42,7 +43,7 @@ export function useLoginGuard(inline: boolean) { setPass(true); } } - }, [address, asPath, pathname, router, inline]); + }, [address, asPath, pathname, router, inline, loginAccount]); return { pass: (!mounted && inline) || pass,