Skip to content

Commit

Permalink
Preserve certain keystates always
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwenmemon committed Dec 13, 2022
1 parent 3a49c3f commit 390ea5f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libs/actions/SignInRedirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,14 @@ function clearStorageAndRedirect(errorMessage) {
// We pass these into the clear() method in order to avoid having to reset them on a delayed tick and getting
// flashes of unwanted default state.
const keysToPreserve = [];
keysToPreserve.push(ONYXKEYS.NVP_PREFERRED_LOCALE);
keysToPreserve.push(ONYXKEYS.ACTIVE_CLIENTS);

// After signing out, set ourselves as offline if we were offline before logging out and we are not forcing it.
// If we are forcing offline, ignore it while signed out, otherwise it would require a refresh because there's no way to toggle the switch to go back online while signed out.
if (currentIsOffline && !currentShouldForceOffline) {
keysToPreserve.push(ONYXKEYS.NETWORK);
}
if (currentPreferredLocale) {
keysToPreserve.push(ONYXKEYS.NVP_PREFERRED_LOCALE);
}
if (currentActiveClients && currentActiveClients.length > 0) {
keysToPreserve.push(ONYXKEYS.ACTIVE_CLIENTS);
}

// Clearing storage discards the authToken. This causes a redirect to the SignIn screen
Onyx.clear(keysToPreserve)
Expand Down

0 comments on commit 390ea5f

Please sign in to comment.