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 @@ -28,7 +28,7 @@ type KeyserverStoreOperation, } from '../ops/keyserver-store-ops.js'; import { queueActivityUpdatesActionType } from '../types/activity-types.js'; -import type { KeyserverStore, KeyserverInfos } from '../types/keyserver-types'; +import type { KeyserverStore } from '../types/keyserver-types.js'; import type { BaseAction } from '../types/redux-types.js'; import { fullStateSyncActionType, @@ -421,36 +421,35 @@ keyserverInfos: processStoreOps(state.keyserverInfos, operations), }; } else if (action.type === deleteKeyserverAccountActionTypes.success) { - const keyserverIDsToRemove = new Set(action.payload.keyserverIDs); - const newKeyserverInfos: { ...KeyserverInfos } = {}; - - const { keyserverInfos } = state; - - for (const keyserverID in keyserverInfos) { - if (!keyserverIDsToRemove.has(keyserverID)) { - newKeyserverInfos[keyserverID] = keyserverInfos[keyserverID]; - continue; - } - if (keyserverID === ashoatKeyserverID) { - const oldConnection = - state.keyserverInfos[ashoatKeyserverID].connection; - - newKeyserverInfos[ashoatKeyserverID] = { - ...state.keyserverInfos[ashoatKeyserverID], - connection: { - ...oldConnection, - connectionIssue: null, - queuedActivityUpdates: [], - lateResponses: [], + const operations: KeyserverStoreOperation[] = [ + { + type: 'remove_keyservers', + payload: { ids: action.payload.keyserverIDs }, + }, + ]; + if (state.keyserverInfos[ashoatKeyserverID]) { + const oldConnection = state.keyserverInfos[ashoatKeyserverID].connection; + operations.push({ + type: 'replace_keyserver', + payload: { + id: ashoatKeyserverID, + keyserverInfo: { + ...state.keyserverInfos[ashoatKeyserverID], + connection: { + ...oldConnection, + connectionIssue: null, + queuedActivityUpdates: [], + lateResponses: [], + }, + cookie: null, }, - cookie: null, - }; - } + }, + }); } return { ...state, - keyserverInfos: newKeyserverInfos, + keyserverInfos: processStoreOps(state.keyserverInfos, operations), }; } else if (action.type === setLateResponseActionType) { const { messageID, isLate, keyserverID } = action.payload;