ViewSyncs: Save message after modifying it

This commit is contained in:
Scott Nonnenberg 2022-12-19 11:11:04 -08:00 committed by GitHub
parent 0613025f95
commit 2d6f13a8c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,8 +90,10 @@ export class ViewSyncs extends Collection {
notificationService.removeBy({ messageId: found.id });
const message = window.MessageController.register(found.id, found);
let didChangeMessage = false;
if (message.get('readStatus') !== ReadStatus.Viewed) {
didChangeMessage = true;
message.set(markViewed(message.attributes, sync.get('viewedAt')));
const attachments = message.get('attachments');
@ -102,6 +104,7 @@ export class ViewSyncs extends Collection {
const giftBadge = message.get('giftBadge');
if (giftBadge) {
didChangeMessage = true;
message.set({
giftBadge: {
...giftBadge,
@ -112,6 +115,10 @@ export class ViewSyncs extends Collection {
});
}
if (didChangeMessage) {
window.Signal.Util.queueUpdateMessage(message.attributes);
}
this.remove(sync);
} catch (error) {
log.error('ViewSyncs.onSync error:', Errors.toLogFormat(error));