From 14d5ed9228c569f31c8cf34f6e1757c1b0a637b8 Mon Sep 17 00:00:00 2001 From: Tomasz Palys Date: Fri, 24 Jan 2025 19:12:17 +0100 Subject: [PATCH] [lib] Update the DMs status to failed after fetching from the DB Summary: After the app is restarted, all the messages that weren't sent fully should be marked as failed so that they can be retried. We wanted to do that but by mistake were using an invalid field to check the condition. https://linear.app/comm/issue/ENG-10111/local-dm-message-stalls-indefinitely Test Plan: Created a pending message following https://linear.app/comm/issue/ENG-10111/local-dm-message-stalls-indefinitely#comment-fccc6bb4 scenario. Then applied this patch and noticed that the message was displayed correctly as failed and could be retried. Reviewers: kamil, bartek Reviewed By: kamil Subscribers: ashoat Differential Revision: https://phab.comm.dev/D14253 --- lib/reducers/message-reducer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js index c83b691a8d..fbe7dccf3f 100644 --- a/lib/reducers/message-reducer.js +++ b/lib/reducers/message-reducer.js @@ -96,6 +96,7 @@ import { messageTruncationStatus, defaultNumberPerThread, type ThreadMessageInfo, + type MessageStoreLocalMessageInfos, } from '../types/message-types.js'; import type { RawImagesMessageInfo } from '../types/messages/images.js'; import type { RawMediaMessageInfo } from '../types/messages/media.js'; @@ -1736,7 +1737,7 @@ function reduceMessageStore( action.payload.messageStoreThreads ?? [], ); - const actionPayloadMessageStoreLocalMessageInfos = + const actionPayloadMessageStoreLocalMessageInfos: MessageStoreLocalMessageInfos = action.payload.messageStoreLocalMessageInfos ?? {}; const messageStoreOperations: Array = []; @@ -1744,9 +1745,9 @@ function reduceMessageStore( for (const localMessageID in actionPayloadMessageStoreLocalMessageInfos) { if ( actionPayloadMessageStoreLocalMessageInfos[localMessageID] - .outboundP2PMessages && + .outboundP2PMessageIDs && actionPayloadMessageStoreLocalMessageInfos[localMessageID] - .outboundP2PMessages.length > 0 + .outboundP2PMessageIDs.length > 0 ) { // If there are `outboundP2PMessages` it means the message failed, // but setting `sendFailed` could not be done, e.g. when the app was