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`.
This commit is contained in:
infinite-persistence 2022-04-11 14:30:42 +08:00 committed by Thomas Zarebczan
parent f7cb0e40cc
commit 5288fb3de8

View file

@ -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());
}
};
}