diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js --- a/lib/reducers/thread-reducer.js +++ b/lib/reducers/thread-reducer.js @@ -352,11 +352,9 @@ }; } - const newThreadInfos = { ...state.threadInfos }; const threadStoreOperations: ThreadStoreOperation[] = []; if (rawThreadInfos) { for (const rawThreadInfo of rawThreadInfos) { - newThreadInfos[rawThreadInfo.id] = rawThreadInfo; threadStoreOperations.push({ type: 'replace', payload: { @@ -367,9 +365,6 @@ } } if (deleteThreadIDs) { - for (const deleteThreadID of deleteThreadIDs) { - delete newThreadInfos[deleteThreadID]; - } threadStoreOperations.push({ type: 'remove', payload: { @@ -378,21 +373,19 @@ }); } + const updatedThreadStore = processThreadStoreOperations( + state, + threadStoreOperations, + ); + const newThreadInconsistencies = findInconsistencies( action, state.threadInfos, - newThreadInfos, - ); - const updatedStore = { - threadInfos: newThreadInfos, - }; - const processedStore = processThreadStoreOperations( - state, - threadStoreOperations, + updatedThreadStore.threadInfos, ); - assertThreadStoreThreadsAreEqual(processedStore, updatedStore, action.type); + return { - threadStore: updatedStore, + threadStore: updatedThreadStore, newThreadInconsistencies, threadStoreOperations, };