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 @@ -100,8 +100,11 @@ processUpdatesActionType, } from '../types/update-types.js'; import { setNewSessionActionType } from '../utils/action-utils.js'; +import { isDev } from '../utils/dev-utils.js'; import { translateClientDBMessageInfosToRawMessageInfos } from '../utils/message-ops-utils.js'; +import { assertObjectsAreEqual } from '../utils/objects.js'; +const PROCESSED_MSG_STORE_INVARIANTS_DISABLED = !isDev; const _mapValuesWithKeys = _mapValues.convert({ cap: false }); // Input must already be ordered! @@ -133,6 +136,22 @@ ); } +function assertMessageStoreThreadsAreEqual( + processedMessageStore: MessageStore, + expectedMessageStore: MessageStore, + location: string, +) { + if (PROCESSED_MSG_STORE_INVARIANTS_DISABLED) { + return; + } + + assertObjectsAreEqual( + processedMessageStore.threads, + expectedMessageStore.threads, + `MessageStore.threads - ${location}`, + ); +} + const newThread = () => ({ messageIDs: [], startReached: false,