Skip to content

Commit

Permalink
[lib] Add timestamp check when flipping unread status
Browse files Browse the repository at this point in the history
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
  • Loading branch information
graszka22 committed Oct 24, 2024
1 parent 0ea10cd commit b0cce8b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/shared/dm-ops/dm-op-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b0cce8b

Please sign in to comment.