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 @@ -28,7 +28,10 @@ +[string]: RawThreadInfo, }, threadStoreOperations: $ReadOnlyArray, -): IntegrityStore { +): { + +integrityStore: IntegrityStore, + +integrityStoreOperations: $ReadOnlyArray, +} { if ( action.type === logInActionTypes.success || action.type === siweAuthActionTypes.success || @@ -40,16 +43,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( @@ -64,6 +74,7 @@ }; newState = processStoreOps(state, [replaceOperation]); + integrityOperations.push(replaceOperation); } if (action.payload.threadHashingStatus) { newState = { @@ -73,9 +84,11 @@ } } if (threadStoreOperations.length === 0) { - return newState; + return { + integrityStore: newState, + integrityStoreOperations: integrityOperations, + }; } - const integrityOperations: IntegrityStoreOperation[] = []; let threadHashingStatus = newState.threadHashingStatus; for (const operation of threadStoreOperations) { if (operation.type === 'replace') { @@ -99,9 +112,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,