diff --git a/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.native.ts b/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.native.ts index 451a35d5bf6c..2a68b30e0874 100644 --- a/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.native.ts +++ b/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.native.ts @@ -8,6 +8,9 @@ function getSettingsTabStateFromSessionStorage(): PartialState return undefined; } +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function clearSessionStorage() {} + // eslint-disable-next-line @typescript-eslint/no-unused-vars function getLastVisitedSettingsPath(state: NavigationState | PartialState): Route | undefined { return undefined; @@ -17,4 +20,4 @@ function getLastVisitedWorkspaceScreen() { return undefined; } -export {getLastVisitedWorkspaceScreen, getLastVisitedSettingsPath, saveSettingsTabPathToSessionStorage, getSettingsTabStateFromSessionStorage}; +export {getLastVisitedWorkspaceScreen, getLastVisitedSettingsPath, saveSettingsTabPathToSessionStorage, getSettingsTabStateFromSessionStorage, clearSessionStorage}; diff --git a/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.ts b/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.ts index b5540400019c..f4f3c423237a 100644 --- a/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.ts +++ b/src/libs/Navigation/helpers/getLastVisitedWorkspace/index.ts @@ -8,6 +8,10 @@ function saveSettingsTabPathToSessionStorage(url: string) { sessionStorage.setItem(CONST.SESSION_STORAGE_KEYS.LAST_VISITED_SETTINGS_TAB_PATH, url); } +function clearSessionStorage() { + sessionStorage.clear(); +} + function getSettingsTabStateFromSessionStorage(): PartialState | undefined { const lastVisitedSettingsPath = sessionStorage.getItem(CONST.SESSION_STORAGE_KEYS.LAST_VISITED_SETTINGS_TAB_PATH); if (!lastVisitedSettingsPath) { @@ -34,4 +38,4 @@ function getLastVisitedWorkspaceScreen() { return workspaceScreenName ?? undefined; } -export {getLastVisitedWorkspaceScreen, getLastVisitedSettingsPath, saveSettingsTabPathToSessionStorage, getSettingsTabStateFromSessionStorage}; +export {getLastVisitedWorkspaceScreen, getLastVisitedSettingsPath, saveSettingsTabPathToSessionStorage, getSettingsTabStateFromSessionStorage, clearSessionStorage}; diff --git a/src/libs/actions/SignInRedirect.ts b/src/libs/actions/SignInRedirect.ts index e20c02f2d465..7def8b69da58 100644 --- a/src/libs/actions/SignInRedirect.ts +++ b/src/libs/actions/SignInRedirect.ts @@ -1,5 +1,6 @@ import Onyx from 'react-native-onyx'; import {getMicroSecondOnyxErrorWithMessage} from '@libs/ErrorUtils'; +import {clearSessionStorage} from '@libs/Navigation/helpers/getLastVisitedWorkspace'; import type {OnyxKey} from '@src/ONYXKEYS'; import ONYXKEYS from '@src/ONYXKEYS'; import {clearAllPolicies} from './Policy/Policy'; @@ -50,7 +51,9 @@ function clearStorageAndRedirect(errorMessage?: string): Promise { * @param [errorMessage] error message to be displayed on the sign in page */ function redirectToSignIn(errorMessage?: string): Promise { - return clearStorageAndRedirect(errorMessage); + return clearStorageAndRedirect(errorMessage).then(() => { + clearSessionStorage(); + }); } export default redirectToSignIn;