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 @@ -1660,6 +1660,21 @@ const actionPayloadMessageStoreLocalMessageInfos = action.payload.messageStoreLocalMessageInfos ?? {}; + for (const localMessageID in actionPayloadMessageStoreLocalMessageInfos) { + if ( + actionPayloadMessageStoreLocalMessageInfos[localMessageID] + .outboundP2PMessages && + actionPayloadMessageStoreLocalMessageInfos[localMessageID] + .outboundP2PMessages.length > 0 + ) { + // If there are `outboundP2PMessages` it means the message failed, + // but setting `sendFailed` could not be done, e.g. when the app was + // killed in the process of sending messages. + actionPayloadMessageStoreLocalMessageInfos[localMessageID].sendFailed = + true; + } + } + const newThreads: { [threadID: string]: ThreadMessageInfo, } = { ...messageStore.threads }; diff --git a/lib/types/message-types.js b/lib/types/message-types.js --- a/lib/types/message-types.js +++ b/lib/types/message-types.js @@ -439,8 +439,12 @@ // Tracks client-local information about a message that hasn't been assigned an // ID by the server yet. As soon as the client gets an ack from the server for // this message, it will clear the LocalMessageInfo. +// For DMs, it keeps track of P2P Messages that are not yet sent. +// As soon as messages are queued on Tunnelbroker, it will +// clear the LocalMessageInfo. export type LocalMessageInfo = { +sendFailed?: boolean, + +outboundP2PMessageIDs?: $ReadOnlyArray, }; const localMessageInfoValidator: TInterface = tShape({