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 @@ -78,19 +78,27 @@ }; } else if (action.type === resetUserStateActionType) { // this action is only dispatched on native - const keyserverInfos = { ...state.keyserverInfos }; - for (const keyserverID in keyserverInfos) { + const replaceOperations: ReplaceKeyserverOperation[] = []; + for (const keyserverID in state.keyserverInfos) { const stateCookie = state.keyserverInfos[keyserverID]?.cookie; - const cookie = - stateCookie && stateCookie.startsWith('anonymous=') - ? stateCookie - : null; - keyserverInfos[keyserverID] = { ...keyserverInfos[keyserverID], cookie }; + if (stateCookie && stateCookie.startsWith('anonymous=')) { + continue; + } + replaceOperations.push({ + type: 'replace_keyserver', + payload: { + id: keyserverID, + keyserverInfo: { + ...state.keyserverInfos[keyserverID], + cookie: null, + }, + }, + }); } return { ...state, - keyserverInfos, + keyserverInfos: processStoreOps(state.keyserverInfos, replaceOperations), }; } else if (action.type === setNewSessionActionType) { const { keyserverID, sessionChange } = action.payload;