From b0cce8b61c26d4c2707f3447d1fbeff4c15c2695 Mon Sep 17 00:00:00 2001 From: Angelika Serwa Date: Tue, 22 Oct 2024 14:24:07 +0200 Subject: [PATCH] [lib] Add timestamp check when flipping unread status Summary: This diff fixes messages appearing unread by adding a timestamp check when getting new messages. https://linear.app/comm/issue/ENG-9727/thick-threads-appearing-unread Test Plan: 1. User A logs to web and mobile 2. User B logs to web 3. User's A mobile is in background 4. User B sends DM to A 5. User A reads the message on web 6. User A brings mobile back to foreground. Verify the last message is not unread. 7. Repeat a few times Reviewers: kamil, tomek Reviewed By: tomek Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D13766 --- lib/shared/dm-ops/dm-op-utils.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/shared/dm-ops/dm-op-utils.js b/lib/shared/dm-ops/dm-op-utils.js index 3db1524524..77b3287289 100644 --- a/lib/shared/dm-ops/dm-op-utils.js +++ b/lib/shared/dm-ops/dm-op-utils.js @@ -459,16 +459,15 @@ function getThreadUpdatesForNewMessages( const time = Math.max(messagesFromOtherPeers.map(message => message.time)); invariant(threadInfo.thick, 'Thread should be thick'); - // We aren't checking if the unread timestamp is lower than the time. - // We're doing this because we want to flip the thread to unread after - // any new message from a non-viewer. - newUpdateInfos.push({ - type: updateTypes.UPDATE_THREAD_READ_STATUS, - id: uuid.v4(), - time, - threadID: threadInfo.id, - unread: true, - }); + if (threadInfo.timestamps.currentUser.unread < time) { + newUpdateInfos.push({ + type: updateTypes.UPDATE_THREAD_READ_STATUS, + id: uuid.v4(), + time, + threadID: threadInfo.id, + unread: true, + }); + } } return newUpdateInfos;