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 @@ -444,11 +444,24 @@ action.payload.userID !== action.payload.preRequestUserState?.id) ) { // We want to remove all keyservers but Ashoat's keyserver - const oldConnection = - state.keyserverInfos[authoritativeKeyserverID()].connection; + const oldKeyserverInfo = state.keyserverInfos[authoritativeKeyserverID()]; + const oldConnection = oldKeyserverInfo.connection; const operations: KeyserverStoreOperation[] = [ { type: 'remove_all_keyservers' }, ]; + + let cookie = oldKeyserverInfo.cookie; + if ( + action.type === logOutActionTypes.success || + action.type === deleteAccountActionTypes.success || + cookie?.startsWith('user=') + ) { + // To avoid unnecessary rerenders, we won't clear the authoritative + // keyserver's cookie unless it's a logout or an account deletion, or if + // the cookie belongs to an actual user (as opposed to an anonymous one) + cookie = null; + } + operations.push({ type: 'replace_keyserver', payload: { @@ -465,7 +478,7 @@ queuedActivityUpdates: [], lateResponses: [], }, - cookie: null, + cookie, }, }, });