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 @@ -1613,8 +1613,14 @@ }, }; } else if (action.type === setClientDBStoreActionType) { + const payloadMessages = action.payload.messages; + if (!payloadMessages) { + return { messageStoreOperations: [], messageStore }; + } const actionPayloadMessageStoreThreads = - translateClientDBThreadMessageInfos(action.payload.messageStoreThreads); + translateClientDBThreadMessageInfos( + action.payload.messageStoreThreads ?? [], + ); const newThreads = {}; for (const threadID in actionPayloadMessageStoreThreads) { @@ -1649,7 +1655,7 @@ } const threadsNeedMsgIDsResorting = new Set(); const actionPayloadMessages = - translateClientDBMessageInfosToRawMessageInfos(action.payload.messages); + translateClientDBMessageInfosToRawMessageInfos(payloadMessages); // When starting the app on native, we filter out any local-only multimedia // messages because the relevant context is no longer available 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 @@ -473,7 +473,7 @@ }; } else if (action.type === setClientDBStoreActionType) { return { - threadStore: action.payload.threadStore, + threadStore: action.payload.threadStore ?? state, newThreadInconsistencies: [], threadStoreOperations: [], }; diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -599,9 +599,9 @@ +payload: { +currentUserID: ?string, +drafts: $ReadOnlyArray, - +messages: $ReadOnlyArray, - +threadStore: ThreadStore, - +messageStoreThreads: $ReadOnlyArray, + +messages: ?$ReadOnlyArray, + +threadStore: ?ThreadStore, + +messageStoreThreads: ?$ReadOnlyArray, }, } | {