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 @@ -1126,31 +1126,27 @@ const local = _pickBy( (localInfo: LocalMessageInfo, key: string) => key !== payload.localID, )(messageStore.local); - const updatedMessageStore = { - messages: newMessages, - threads: { - ...messageStore.threads, - [threadID]: { - ...messageStore.threads[threadID], - messageIDs: newMessageIDs, - }, - }, - local, - currentAsOf, - }; const processedMessageStore = processMessageStoreOperations( messageStore, messageStoreOperations, ); - assertMessageStoreMessagesAreEqual( - processedMessageStore, - updatedMessageStore, - action.type, - ); - - return { messageStoreOperations, messageStore: updatedMessageStore }; + return { + messageStoreOperations, + messageStore: { + messages: processedMessageStore.messages, + threads: { + ...messageStore.threads, + [threadID]: { + ...messageStore.threads[threadID], + messageIDs: newMessageIDs, + }, + }, + local, + currentAsOf, + }, + }; } else if (action.type === saveMessagesActionType) { const truncationStatuses = {}; for (const messageInfo of action.payload.rawMessageInfos) { @@ -1206,32 +1202,26 @@ newThreads[threadID] = thread; } - const prunedMessageStore = { - messages: _omit(messageIDsToPrune)(messageStore.messages), - threads: newThreads, - local: _omit(messageIDsToPrune)(messageStore.local), - currentAsOf: messageStore.currentAsOf, - }; - const messageStoreOperations = [ { type: 'remove', payload: { ids: messageIDsToPrune }, }, ]; - const processedMessageStore = processMessageStoreOperations( messageStore, messageStoreOperations, ); - assertMessageStoreMessagesAreEqual( - processedMessageStore, - prunedMessageStore, - action.type, - ); - - return { messageStoreOperations, messageStore: prunedMessageStore }; + return { + messageStoreOperations, + messageStore: { + messages: processedMessageStore.messages, + threads: newThreads, + local: _omit(messageIDsToPrune)(messageStore.local), + currentAsOf: messageStore.currentAsOf, + }, + }; } else if (action.type === updateMultimediaMessageMediaActionType) { const { messageID: id, currentMediaID, mediaUpdate } = action.payload; const message = messageStore.messages[id]; @@ -1409,12 +1399,6 @@ if (newThreads === threads) { return { messageStoreOperations: [], messageStore }; } - const newMessageStore = { - ...messageStore, - messages: newMessages, - threads: newThreads, - local: newLocal, - }; const messageStoreOperations: MessageStoreOperation[] = [ { @@ -1427,13 +1411,15 @@ messageStoreOperations, ); - assertMessageStoreMessagesAreEqual( - processedMessageStore, - newMessageStore, - action.type, - ); - - return { messageStoreOperations, messageStore: newMessageStore }; + return { + messageStoreOperations, + messageStore: { + ...messageStore, + messages: processedMessageStore.messages, + threads: newThreads, + local: newLocal, + }, + }; } else if (action.type === processServerRequestsActionType) { const { messageStoreOperations,