Update contents of conversation even when view not hydrated

Also ensure that we update the last message in a conversation after
expire, after the mesage is really deleted from the database.
This commit is contained in:
Scott Nonnenberg 2018-06-25 14:51:06 -07:00
parent 4415293100
commit 12b5547e72
3 changed files with 39 additions and 31 deletions

View file

@ -5,7 +5,7 @@
function destroyExpiredMessages() {
// Load messages that have expired and destroy them
var expired = new Whisper.MessageCollection();
expired.on('add', function(message) {
expired.on('add', async function(message) {
console.log('Message expired', {
sentAt: message.get('sent_at'),
});
@ -16,7 +16,10 @@
// We delete after the trigger to allow the conversation time to process
// the expiration before the message is removed from the database.
message.destroy();
await wrapDeferred(message.destroy());
if (conversation) {
conversation.updateLastMessage();
}
});
expired.on('reset', throttledCheckExpiringMessages);