Expire Timer: If we generated change, don't mark unread

This commit is contained in:
Scott Nonnenberg 2022-09-06 16:52:07 -07:00 committed by GitHub
parent 6a1b6f2e44
commit 56ffd7bc3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 5 deletions

View File

@ -2778,9 +2778,11 @@ export async function startApp(): Promise<void> {
}
await conversation.updateExpirationTimer(expireTimer, {
// Note: because it's our conversationId, this notification will be marked read. But
// setting this will make 'isSetByOther' check true.
source: window.ConversationController.getOurConversationId(),
fromSync: true,
receivedAt: ev.receivedAtCounter,
source: window.ConversationController.getOurConversationId(),
reason: 'group sync',
});
}

View File

@ -4428,7 +4428,9 @@ export class ConversationModel extends window.Backbone
}
}
source = source || window.ConversationController.getOurConversationId();
const ourConversationId =
window.ConversationController.getOurConversationId();
source = source || ourConversationId;
this.set({ expireTimer });
@ -4442,8 +4444,13 @@ export class ConversationModel extends window.Backbone
// to be above the message that initiated that change, hence the subtraction.
const sentAt = (providedSentAt || receivedAtMS) - 1;
const isFromSyncOperation =
reason === 'group sync' || reason === 'contact sync';
const isFromMe =
window.ConversationController.get(source)?.id === ourConversationId;
const isNoteToSelf = isMe(this.attributes);
const shouldBeRead = isNoteToSelf || isInitialSync;
const shouldBeRead =
(isInitialSync && isFromSyncOperation) || isFromMe || isNoteToSelf;
const model = new window.Whisper.Message({
conversationId: this.id,

View File

@ -2663,7 +2663,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// point and these calls will return early.
if (dataMessage.expireTimer) {
conversation.updateExpirationTimer(dataMessage.expireTimer, {
source,
source: sourceUuid || source,
receivedAt: message.get('received_at'),
receivedAtMS: message.get('received_at_ms'),
sentAt: message.get('sent_at'),
@ -2676,7 +2676,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
!isEndSession(message.attributes)
) {
conversation.updateExpirationTimer(undefined, {
source,
source: sourceUuid || source,
receivedAt: message.get('received_at'),
receivedAtMS: message.get('received_at_ms'),
sentAt: message.get('sent_at'),

View File

@ -61,6 +61,8 @@ async function updateConversationFromContactSync(
// expireTimer isn't in Storage Service so we have to rely on contact sync.
await conversation.updateExpirationTimer(details.expireTimer, {
// Note: because it's our conversationId, this notification will be marked read. But
// setting this will make 'isSetByOther' check true.
source: window.ConversationController.getOurConversationId(),
receivedAt: receivedAtCounter,
fromSync: true,