Mark stories as viewed if we have a view sync during modifyTargetMessage

This commit is contained in:
Josh Perez 2022-08-16 19:45:03 -04:00 committed by GitHub
parent 201c6f9078
commit ce77465d23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3021,18 +3021,36 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
}
if (
isStory(message.attributes) &&
!message.get('expirationStartTimestamp')
) {
message.set(
'expirationStartTimestamp',
Math.min(
message.get('serverTimestamp') || message.get('timestamp'),
Date.now()
)
);
changed = true;
if (isStory(message.attributes)) {
const viewSyncs = ViewSyncs.getSingleton().forMessage(message);
if (viewSyncs.length !== 0) {
message.set({
readStatus: ReadStatus.Viewed,
seenStatus: SeenStatus.Seen,
});
changed = true;
const markReadAt = Math.min(
Date.now(),
...viewSyncs.map(sync => sync.get('viewedAt'))
);
this.pendingMarkRead = Math.min(
this.pendingMarkRead ?? Date.now(),
markReadAt
);
}
if (!message.get('expirationStartTimestamp')) {
message.set(
'expirationStartTimestamp',
Math.min(
message.get('serverTimestamp') || message.get('timestamp'),
Date.now()
)
);
changed = true;
}
}
// Does this message have any pending, previously-received associated reactions?