From 5288fb3de8fe595c24ee5519de895c41f4408fc1 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Mon, 11 Apr 2022 14:30:42 +0800 Subject: [PATCH] Fix signout sequence not cleaning up correctly Potentially closes 1319 ## Note - `persistor.purge` returns a promise, we should wait for the resolved results before reloading, instead of just adding an arbitrary `setTimeout`. - Perhaps the `setTimeout` method is to ignore a super-long or hanged purge (not sure), but it wouldn't be right since it would end up in a limbo state. - Log errors to get clues for future. - Reduced code by moving the reload to `finally`. --- ui/redux/actions/app.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ui/redux/actions/app.js b/ui/redux/actions/app.js index 7384748af..a5ad7ad3e 100644 --- a/ui/redux/actions/app.js +++ b/ui/redux/actions/app.js @@ -550,15 +550,13 @@ export function doSignOut() { .then(doSignOutCleanup) .then(() => { // @if TARGET='web' - window.persistor.purge(); + return window.persistor.purge(); // @endif }) - .then(() => { - setTimeout(() => { - location.reload(); - }); + .catch((err) => { + analytics.error(`\`doSignOut\`: ${err.message || err}`); }) - .catch(() => location.reload()); + .finally(() => location.reload()); } }; }