fix: prevent logout 401 and login double-attempt caused by LWW layout push race
resetUserStores() was abusing populateFromReady('', [], [], []) to clear the
space store. Its LWW timestamp logic fired an async pushLayoutToOrigin when
_layoutUpdatedAt > 0, which read a null token from localStorage (already
removed on logout, not yet set on login). The 401 response triggered
handleUnauthorized(), deleting the freshly-stored login token and forcing a
full page reload — requiring users to log in twice.
Replace with a proper reset() method that synchronously sets all state to
initial values with no LWW comparison or API side effects.
This commit is contained in:
@@ -31,7 +31,7 @@ interface AuthState {
|
||||
function resetUserStores() {
|
||||
clearSelfIds();
|
||||
useChatStore.getState().clearAllMessages();
|
||||
useSpaceStore.getState().populateFromReady('', [], [], []);
|
||||
useSpaceStore.getState().reset();
|
||||
useSocialStore.getState().reset();
|
||||
useVoiceStore.getState().resetSession();
|
||||
useInstanceStore.getState().reset();
|
||||
|
||||
Reference in New Issue
Block a user