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 @@ -472,6 +472,13 @@ threadStoreOperations, }; } else if (action.type === setClientDBStoreActionType) { + if (!action.payload.threadStore) { + return { + threadStore: state, + newThreadInconsistencies: [], + threadStoreOperations: [], + }; + } return { threadStore: action.payload.threadStore, newThreadInconsistencies: [], 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 @@ -595,9 +595,9 @@ +payload: { +currentUserID: ?string, +drafts: $ReadOnlyArray, - +messages: $ReadOnlyArray, - +threadStore: ThreadStore, - +messageStoreThreads: $ReadOnlyArray, + +messages: ?$ReadOnlyArray, + +threadStore: ?ThreadStore, + +messageStoreThreads: ?$ReadOnlyArray, }, } | {