Skip to content

Commit

Permalink
remove return promise
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Sep 28, 2021
1 parent f3e3f82 commit ccef3d9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/libs/actions/SignInRedirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@ Onyx.connect({

/**
* @param {String} errorMessage
* @returns {Promise}
*/
function clearStorageAndRedirect(errorMessage) {
const activeClients = currentActiveClients;
const preferredLocale = currentPreferredLocale;

// Clearing storage discards the authToken. This causes a redirect to the SignIn screen
return Onyx.clear()
Onyx.clear()
.then(() => {
const promises = [];

if (preferredLocale) {
promises.push(Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, preferredLocale));
Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, preferredLocale);
}
if (activeClients && activeClients.length > 0) {
promises.push(Onyx.set(ONYXKEYS.ACTIVE_CLIENTS, activeClients));
Onyx.set(ONYXKEYS.ACTIVE_CLIENTS, activeClients);
}

// `Onyx.clear` reinitialize the Onyx instance with initial values so use `Onyx.merge` instead of `Onyx.set`.
promises.push(Onyx.merge(ONYXKEYS.SESSION, {error: errorMessage}));
return Promise.all(promises);
Onyx.merge(ONYXKEYS.SESSION, {error: errorMessage});
});
}

Expand Down

0 comments on commit ccef3d9

Please sign in to comment.