Use read sync timestamp to do unread bookkeeping

This commit is contained in:
Josh Perez 2023-09-13 10:42:33 -04:00 committed by GitHub
parent ed92d244b2
commit fc34cd88b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View file

@ -115,6 +115,7 @@ export async function onSync(sync: ReadSyncAttributesType): Promise<void> {
const message = window.MessageController.register(found.id, found);
const readAt = Math.min(sync.readAt, Date.now());
const newestSentAt = sync.timestamp;
// If message is unread, we mark it read. Otherwise, we update the expiration
// timer to the time specified by the read sync if it's earlier than
@ -127,7 +128,11 @@ export async function onSync(sync: ReadSyncAttributesType): Promise<void> {
// onReadMessage may result in messages older than this one being
// marked read. We want those messages to have the same expire timer
// start time as this one, so we pass the readAt value through.
drop(message.getConversation()?.onReadMessage(message, readAt));
drop(
message
.getConversation()
?.onReadMessage(message, readAt, newestSentAt)
);
};
// only available during initialization