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:
Jannis Braun
2026-03-16 22:52:32 +01:00
parent 1c806be94f
commit bf64c4678b
2 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -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();