When marking message read, ensure that peers have same read_at
When we mark a message as read, we go to the database to ensure that older messages in this conversation are marked read as well. That optimization was missing the read_at value provided to the starting message, so now it is piped along to all of them.
This commit is contained in:
parent
9400d1a538
commit
8c85f6e3a6
3 changed files with 15 additions and 10 deletions
|
@ -541,7 +541,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onReadMessage(message) {
|
onReadMessage(message, readAt) {
|
||||||
if (this.messageCollection.get(message.id)) {
|
if (this.messageCollection.get(message.id)) {
|
||||||
this.messageCollection.get(message.id).fetch();
|
this.messageCollection.get(message.id).fetch();
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,10 @@
|
||||||
// Lastly, we don't send read syncs for any message marked read due to a read
|
// Lastly, we don't send read syncs for any message marked read due to a read
|
||||||
// sync. That's a notification explosion we don't need.
|
// sync. That's a notification explosion we don't need.
|
||||||
return this.queueJob(() =>
|
return this.queueJob(() =>
|
||||||
this.markRead(message.get('received_at'), { sendReadReceipts: false })
|
this.markRead(message.get('received_at'), {
|
||||||
|
sendReadReceipts: false,
|
||||||
|
readAt,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1018,7 +1021,7 @@
|
||||||
'it was not in messageCollection.'
|
'it was not in messageCollection.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
promises.push(m.markRead());
|
promises.push(m.markRead(options.readAt));
|
||||||
const errors = m.get('errors');
|
const errors = m.get('errors');
|
||||||
return {
|
return {
|
||||||
sender: m.get('source'),
|
sender: m.get('source'),
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
/* global Signal: false */
|
/* global Signal: false */
|
||||||
/* global textsecure: false */
|
/* global textsecure: false */
|
||||||
/* global Whisper: false */
|
/* global Whisper: false */
|
||||||
|
/* global wrapDeferred: false */
|
||||||
|
|
||||||
/* eslint-disable more/no-then */
|
/* eslint-disable more/no-then */
|
||||||
|
|
||||||
|
@ -798,7 +799,7 @@
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
markRead(readAt) {
|
async markRead(readAt) {
|
||||||
this.unset('unread');
|
this.unset('unread');
|
||||||
if (this.get('expireTimer') && !this.get('expirationStartTimestamp')) {
|
if (this.get('expireTimer') && !this.get('expirationStartTimestamp')) {
|
||||||
this.set('expirationStartTimestamp', readAt || Date.now());
|
this.set('expirationStartTimestamp', readAt || Date.now());
|
||||||
|
@ -808,9 +809,7 @@
|
||||||
messageId: this.id,
|
messageId: this.id,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
return new Promise((resolve, reject) => {
|
return wrapDeferred(this.save());
|
||||||
this.save().then(resolve, reject);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
isExpiring() {
|
isExpiring() {
|
||||||
return this.get('expireTimer') && this.get('expirationStartTimestamp');
|
return this.get('expireTimer') && this.get('expirationStartTimestamp');
|
||||||
|
|
|
@ -45,7 +45,10 @@
|
||||||
return message
|
return message
|
||||||
? message.markRead(receipt.get('read_at')).then(
|
? message.markRead(receipt.get('read_at')).then(
|
||||||
function() {
|
function() {
|
||||||
this.notifyConversation(message);
|
// This notification 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 read_at value through.
|
||||||
|
this.notifyConversation(message, receipt.get('read_at'));
|
||||||
this.remove(receipt);
|
this.remove(receipt);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
)
|
||||||
|
@ -53,13 +56,13 @@
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
notifyConversation: function(message) {
|
notifyConversation: function(message, readAt) {
|
||||||
var conversation = ConversationController.get({
|
var conversation = ConversationController.get({
|
||||||
id: message.get('conversationId'),
|
id: message.get('conversationId'),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (conversation) {
|
if (conversation) {
|
||||||
conversation.onReadMessage(message);
|
conversation.onReadMessage(message, readAt);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}))();
|
}))();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue