diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js --- a/lib/reducers/keyserver-reducer.js +++ b/lib/reducers/keyserver-reducer.js @@ -26,33 +26,29 @@ ): KeyserverStore { // this action is only dispatched on native if (action.type === resetUserStateActionType) { - const stateCookie = state.keyserverInfos[ashoatKeyserverID]?.cookie; - const cookie = - stateCookie && stateCookie.startsWith('anonymous=') ? stateCookie : null; - const keyserverInfos = { ...state.keyserverInfos }; - for (const key in keyserverInfos) { - keyserverInfos[key] = { ...keyserverInfos[key], cookie: null }; + for (const keyserverID in keyserverInfos) { + const stateCookie = state.keyserverInfos[keyserverID]?.cookie; + const cookie = + stateCookie && stateCookie.startsWith('anonymous=') + ? stateCookie + : null; + keyserverInfos[keyserverID] = { ...keyserverInfos[keyserverID], cookie }; } state = { ...state, - keyserverInfos: { - ...keyserverInfos, - [ashoatKeyserverID]: { - ...state.keyserverInfos[ashoatKeyserverID], - cookie, - }, - }, + keyserverInfos, }; } else if (action.type === setNewSessionActionType) { + const { keyserverID } = action.payload; if (action.payload.sessionChange.cookie !== undefined) { state = { ...state, keyserverInfos: { ...state.keyserverInfos, - [ashoatKeyserverID]: { - ...state.keyserverInfos[ashoatKeyserverID], + [keyserverID]: { + ...state.keyserverInfos[keyserverID], cookie: action.payload.sessionChange.cookie, }, }, diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js --- a/lib/socket/socket.react.js +++ b/lib/socket/socket.react.js @@ -635,6 +635,7 @@ preRequestUserState: this.initializedWithUserState, error: null, logInActionSource: undefined, + keyserverID: ashoatKeyserverID, }, }); } diff --git a/lib/types/session-types.js b/lib/types/session-types.js --- a/lib/types/session-types.js +++ b/lib/types/session-types.js @@ -92,6 +92,7 @@ preRequestUserState: ?PreRequestUserState, error: ?string, logInActionSource: ?LogInActionSource, + keyserverID: string, }; export type SessionState = { diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js --- a/lib/utils/action-utils.js +++ b/lib/utils/action-utils.js @@ -171,10 +171,17 @@ preRequestUserState: ?PreRequestUserState, error: ?string, logInActionSource: ?LogInActionSource, + keyserverID: string, ) { dispatch({ type: setNewSessionActionType, - payload: { sessionChange, preRequestUserState, error, logInActionSource }, + payload: { + sessionChange, + preRequestUserState, + error, + logInActionSource, + keyserverID, + }, }); } @@ -207,7 +214,14 @@ error: ?string, ) => { newSessionChange = sessionChange; - setNewSession(dispatch, sessionChange, null, error, logInActionSource); + setNewSession( + dispatch, + sessionChange, + null, + error, + logInActionSource, + keyserverID, + ); }; try { const result = await callServerEndpoint( @@ -306,6 +320,7 @@ { currentUserInfo, cookie, sessionID }, error, undefined, + keyserverID, ); // This function gets called before callServerEndpoint sends a request, // to make sure that we're not in the middle of trying to recover