skip updateLastMessage for inactive convos

those are the ones created when getting messages on a public group.
they are not shown on the conversation list
pull/1459/head
Audric Ackermann 4 years ago
parent 13df6c476e
commit 9645c210dd

@ -849,16 +849,18 @@
); );
await serverAPI.setAvatar(url, profileKey); await serverAPI.setAvatar(url, profileKey);
}, },
async updateLastMessage() { async bouncyUpdateLastMessage() {
if (!this.id) { if (!this.id) {
return; return;
} }
if (!this.get('active_at')) {
window.log.info('Skipping update last message as active_at is falsy');
return;
}
const messages = await window.Signal.Data.getMessagesByConversation( const messages = await window.Signal.Data.getMessagesByConversation(
this.id, this.id,
{ limit: 1, MessageCollection: Whisper.MessageCollection } { limit: 1, MessageCollection: Whisper.MessageCollection }
); );
const lastMessageModel = messages.at(0); const lastMessageModel = messages.at(0);
const lastMessageJSON = lastMessageModel const lastMessageJSON = lastMessageModel
? lastMessageModel.toJSON() ? lastMessageModel.toJSON()
@ -874,12 +876,10 @@
? lastMessageModel.getNotificationText() ? lastMessageModel.getNotificationText()
: null, : null,
}); });
// Because we're no longer using Backbone-integrated saves, we need to manually // Because we're no longer using Backbone-integrated saves, we need to manually
// clear the changed fields here so our hasChanged() check below is useful. // clear the changed fields here so our hasChanged() check below is useful.
this.changed = {}; this.changed = {};
this.set(lastMessageUpdate); this.set(lastMessageUpdate);
if (this.hasChanged()) { if (this.hasChanged()) {
await this.commit(); await this.commit();
} }

Loading…
Cancel
Save