parent
ad05efb7a0
commit
0902c94093
1 changed files with 21 additions and 24 deletions
|
@ -9,7 +9,7 @@
|
|||
'use strict';
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
const { Attachment, Message } = window.Signal.Types;
|
||||
const { Attachment, Conversation, Message } = window.Signal.Types;
|
||||
const { upgradeMessageSchema, loadAttachmentData } = window.Signal.Migrations;
|
||||
|
||||
// TODO: Factor out private and group subclasses of Conversation
|
||||
|
@ -669,32 +669,29 @@
|
|||
));
|
||||
});
|
||||
},
|
||||
|
||||
async updateLastMessage() {
|
||||
const collection = new Whisper.MessageCollection();
|
||||
await collection.fetchConversation(this.id, 1);
|
||||
const lastMessage = collection.at(0);
|
||||
|
||||
const lastMessageUpdate = Conversation.createLastMessageUpdate({
|
||||
currentLastMessageText: this.get('lastMessage') || null,
|
||||
currentTimestamp: this.get('timestamp') || null,
|
||||
lastMessage: lastMessage ? lastMessage.toJSON() : null,
|
||||
lastMessageNotificationText: lastMessage
|
||||
? lastMessage.getNotificationText() : null,
|
||||
});
|
||||
|
||||
this.set(lastMessageUpdate);
|
||||
|
||||
if (this.hasChanged('lastMessage') || this.hasChanged('timestamp')) {
|
||||
this.save();
|
||||
}
|
||||
},
|
||||
/* jshint ignore:end */
|
||||
/* eslint-disable */
|
||||
|
||||
updateLastMessage: function() {
|
||||
var collection = new Whisper.MessageCollection();
|
||||
return collection.fetchConversation(this.id, 1).then(function() {
|
||||
var lastMessage = collection.at(0);
|
||||
if (lastMessage) {
|
||||
var type = lastMessage.get('type');
|
||||
var shouldSkipUpdate = type === 'verified-change' || lastMessage.get('expirationTimerUpdate');
|
||||
if (shouldSkipUpdate) {
|
||||
return;
|
||||
}
|
||||
this.set({
|
||||
lastMessage : lastMessage.getNotificationText(),
|
||||
timestamp : lastMessage.get('sent_at')
|
||||
});
|
||||
} else {
|
||||
this.set({ lastMessage: '', timestamp: null });
|
||||
}
|
||||
if (this.hasChanged('lastMessage') || this.hasChanged('timestamp')) {
|
||||
this.save();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
updateExpirationTimer: function(expireTimer, source, received_at, options) {
|
||||
options = options || {};
|
||||
_.defaults(options, {fromSync: false});
|
||||
|
|
Loading…
Reference in a new issue