From 9183035dfd05e4ea8a68c1af0161af9ec2331ca5 Mon Sep 17 00:00:00 2001 From: Rupato Braganza Date: Tue, 18 Feb 2025 14:06:47 +0800 Subject: [PATCH 1/2] fix: removed extra check --- src/components/layout/index.tsx | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/components/layout/index.tsx b/src/components/layout/index.tsx index 72ae1020..55059b03 100644 --- a/src/components/layout/index.tsx +++ b/src/components/layout/index.tsx @@ -19,27 +19,19 @@ const Layout = () => { const isLoggedInCookie = Cookies.get('logged_state') === 'true'; const isEndpointPage = window.location.pathname.includes('endpoint'); const clientAccounts = JSON.parse(localStorage.getItem('accountsList') ?? '{}'); - const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0; - const clientAccountsMissingToken = - isClientAccountsPopulated && - Object.values(clientAccounts).some(account => !(account as { token?: string }).token); + const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}'); + const checkAccountList = JSON.parse(localStorage.getItem('accountList') ?? '{}'); + const AccountLengthsEqual = JSON.stringify(clientAccounts) === JSON.stringify(checkClientAccount); - console.log('clientAccounts', clientAccountsMissingToken, clientAccounts); + console.log('clientAccounts', { checkClientAccount, checkAccountList, AccountLengthsEqual }); useEffect(() => { - if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage && clientAccountsMissingToken) { + if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage && !AccountLengthsEqual) { console.log('requestOidcAuthentication'); requestOidcAuthentication({ redirectCallbackUri: `${window.location.origin}/callback`, }); } - }, [ - isLoggedInCookie, - isClientAccountsPopulated, - isOAuth2Enabled, - isEndpointPage, - isCallbackPage, - clientAccountsMissingToken, - ]); + }, [isLoggedInCookie, isOAuth2Enabled, isEndpointPage, isCallbackPage]); return (
From aba097f43637a4fcde1ea7bbf23fdeebcdae7f33 Mon Sep 17 00:00:00 2001 From: Rupato Braganza Date: Tue, 18 Feb 2025 14:07:58 +0800 Subject: [PATCH 2/2] fix: removed extra check --- src/components/layout/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/layout/index.tsx b/src/components/layout/index.tsx index 55059b03..07fddea2 100644 --- a/src/components/layout/index.tsx +++ b/src/components/layout/index.tsx @@ -21,17 +21,17 @@ const Layout = () => { const clientAccounts = JSON.parse(localStorage.getItem('accountsList') ?? '{}'); const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}'); const checkAccountList = JSON.parse(localStorage.getItem('accountList') ?? '{}'); - const AccountLengthsEqual = JSON.stringify(clientAccounts) === JSON.stringify(checkClientAccount); + const accountLengthsEqual = JSON.stringify(clientAccounts) === JSON.stringify(checkClientAccount); - console.log('clientAccounts', { checkClientAccount, checkAccountList, AccountLengthsEqual }); + console.log('clientAccounts', { checkClientAccount, checkAccountList, accountLengthsEqual }); useEffect(() => { - if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage && !AccountLengthsEqual) { + if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage && !accountLengthsEqual) { console.log('requestOidcAuthentication'); requestOidcAuthentication({ redirectCallbackUri: `${window.location.origin}/callback`, }); } - }, [isLoggedInCookie, isOAuth2Enabled, isEndpointPage, isCallbackPage]); + }, [isLoggedInCookie, isOAuth2Enabled, isEndpointPage, isCallbackPage, accountLengthsEqual]); return (