Skip to content

Commit

Permalink
fix(dcellar-web-ui): resolve issue with connect-wallet page login jum…
Browse files Browse the repository at this point in the history
…p error
  • Loading branch information
devinxl committed Apr 16, 2024
1 parent 6b4dfdf commit 00594a9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/dcellar-web-ui/src/context/LoginContext/useLoginGuard.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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';
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;

Expand All @@ -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 !== '/') {
Expand All @@ -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,
Expand Down

0 comments on commit 00594a9

Please sign in to comment.