diff --git a/lib/reducers/integrity-reducer.js b/lib/reducers/integrity-reducer.js --- a/lib/reducers/integrity-reducer.js +++ b/lib/reducers/integrity-reducer.js @@ -29,23 +29,28 @@ +[string]: RawThreadInfo, }, threadStoreOperations: $ReadOnlyArray, -): IntegrityStore { +): { + +integrityStore: IntegrityStore, + +integrityStoreOperations: $ReadOnlyArray, +} { if (action.type === fullStateSyncActionType) { const removeAllOperation = { type: 'remove_all_integrity_thread_hashes' }; const threadHashesArray = Object.entries(state.threadHashes).filter( ([key]) => extractKeyserverIDFromID(key) !== action.payload.keyserverID, ); - const threadHashes = Object.fromEntries(threadHashesArray); const replaceOperation = { type: 'replace_integrity_thread_hashes', - payload: { threadHashes }, + payload: { threadHashes: Object.fromEntries(threadHashesArray) }, }; return { - threadHashes: processStoreOps(state, [ - removeAllOperation, - replaceOperation, - ]).threadHashes, - threadHashingStatus: 'starting', + integrityStore: { + threadHashes: processStoreOps(state, [ + removeAllOperation, + replaceOperation, + ]).threadHashes, + threadHashingStatus: 'starting', + }, + integrityStoreOperations: [removeAllOperation, replaceOperation], }; } else if ( action.type === logInActionTypes.success || @@ -57,16 +62,23 @@ ) { const removeAllOperation = { type: 'remove_all_integrity_thread_hashes' }; return { - threadHashes: processStoreOps(state, [removeAllOperation]).threadHashes, - threadHashingStatus: 'starting', + integrityStore: { + threadHashes: processStoreOps(state, [removeAllOperation]).threadHashes, + threadHashingStatus: 'starting', + }, + integrityStoreOperations: [removeAllOperation], }; } else if (action.type === keyserverAuthActionTypes.success) { return { - threadHashes: processStoreOps(state, []).threadHashes, - threadHashingStatus: 'starting', + integrityStore: { + threadHashes: processStoreOps(state, []).threadHashes, + threadHashingStatus: 'starting', + }, + integrityStoreOperations: [], }; } let newState = state; + const integrityOperations: IntegrityStoreOperation[] = []; if (action.type === updateIntegrityStoreActionType) { if (action.payload.threadIDsToHash) { const newThreadHashes = Object.fromEntries( @@ -81,6 +93,7 @@ }; newState = processStoreOps(state, [replaceOperation]); + integrityOperations.push(replaceOperation); } if (action.payload.threadHashingStatus) { newState = { @@ -90,9 +103,11 @@ } } if (threadStoreOperations.length === 0) { - return newState; + return { + integrityStore: newState, + integrityStoreOperations: integrityOperations, + }; } - const integrityOperations: IntegrityStoreOperation[] = []; let groupedReplaceThreadHashes: ThreadHashes = {}; let threadHashingStatus = newState.threadHashingStatus; for (const operation of threadStoreOperations) { @@ -131,9 +146,11 @@ } return { - ...newState, - threadHashes: processStoreOps(newState, integrityOperations).threadHashes, - threadHashingStatus, + integrityStore: { + threadHashes: processStoreOps(newState, integrityOperations).threadHashes, + threadHashingStatus, + }, + integrityStoreOperations: integrityOperations, }; } diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js --- a/lib/reducers/master-reducer.js +++ b/lib/reducers/master-reducer.js @@ -161,6 +161,13 @@ action, ); + const { integrityStore } = reduceIntegrityStore( + state.integrityStore, + action, + threadInfos, + threadStoreOperations, + ); + return { state: { ...state, @@ -197,12 +204,7 @@ state.threadActivityStore, action, ), - integrityStore: reduceIntegrityStore( - state.integrityStore, - action, - threadStore.threadInfos, - threadStoreOperations, - ), + integrityStore, globalThemeInfo: reduceGlobalThemeInfo(state.globalThemeInfo, action), customServer: reduceCustomerServer(state.customServer, action), communityStore,