Skip to content

Commit

Permalink
[lib] Update the DMs status to failed after fetching from the DB
Browse files Browse the repository at this point in the history
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
  • Loading branch information
palys-swm committed Jan 27, 2025
1 parent 83044ff commit 14d5ed9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/reducers/message-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1736,17 +1737,17 @@ function reduceMessageStore(
action.payload.messageStoreThreads ?? [],
);

const actionPayloadMessageStoreLocalMessageInfos =
const actionPayloadMessageStoreLocalMessageInfos: MessageStoreLocalMessageInfos =
action.payload.messageStoreLocalMessageInfos ?? {};

const messageStoreOperations: Array<MessageStoreOperation> = [];

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
Expand Down

0 comments on commit 14d5ed9

Please sign in to comment.