Skip to content

Commit 9183035

Browse files
committed
fix: removed extra check
1 parent c6bb244 commit 9183035

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/components/layout/index.tsx

+6-14
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,19 @@ const Layout = () => {
1919
const isLoggedInCookie = Cookies.get('logged_state') === 'true';
2020
const isEndpointPage = window.location.pathname.includes('endpoint');
2121
const clientAccounts = JSON.parse(localStorage.getItem('accountsList') ?? '{}');
22-
const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0;
23-
const clientAccountsMissingToken =
24-
isClientAccountsPopulated &&
25-
Object.values(clientAccounts).some(account => !(account as { token?: string }).token);
22+
const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}');
23+
const checkAccountList = JSON.parse(localStorage.getItem('accountList') ?? '{}');
24+
const AccountLengthsEqual = JSON.stringify(clientAccounts) === JSON.stringify(checkClientAccount);
2625

27-
console.log('clientAccounts', clientAccountsMissingToken, clientAccounts);
26+
console.log('clientAccounts', { checkClientAccount, checkAccountList, AccountLengthsEqual });
2827
useEffect(() => {
29-
if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage && clientAccountsMissingToken) {
28+
if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage && !AccountLengthsEqual) {
3029
console.log('requestOidcAuthentication');
3130
requestOidcAuthentication({
3231
redirectCallbackUri: `${window.location.origin}/callback`,
3332
});
3433
}
35-
}, [
36-
isLoggedInCookie,
37-
isClientAccountsPopulated,
38-
isOAuth2Enabled,
39-
isEndpointPage,
40-
isCallbackPage,
41-
clientAccountsMissingToken,
42-
]);
34+
}, [isLoggedInCookie, isOAuth2Enabled, isEndpointPage, isCallbackPage]);
4335

4436
return (
4537
<div className={clsx('layout', { responsive: isDesktop })}>

0 commit comments

Comments
 (0)