diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js --- a/lib/reducers/message-reducer.js +++ b/lib/reducers/message-reducer.js @@ -1245,25 +1245,41 @@ (localInfo: LocalMessageInfo, key: string) => key !== payload.localID, )(messageStore.local); + const updatedThreads = { + [threadID]: { + ...messageStore.threads[threadID], + messageIDs: newMessageIDs, + }, + }; + messageStoreOperations.push({ + type: 'replace_threads', + payload: { threads: { ...updatedThreads } }, + }); + const processedMessageStore = processMessageStoreOperations( messageStore, messageStoreOperations, ); + const newMessageStore = { + ...messageStore, + messages: processedMessageStore.messages, + threads: { + ...messageStore.threads, + ...updatedThreads, + }, + local, + }; + + assertMessageStoreThreadsAreEqual( + processedMessageStore, + newMessageStore, + action.type, + ); + return { messageStoreOperations, - messageStore: { - ...messageStore, - messages: processedMessageStore.messages, - threads: { - ...messageStore.threads, - [threadID]: { - ...messageStore.threads[threadID], - messageIDs: newMessageIDs, - }, - }, - local, - }, + messageStore: newMessageStore, }; } else if (action.type === saveMessagesActionType) { const truncationStatuses = {};