|
|
@ -135,6 +135,8 @@
|
|
|
|
this.on('read', this.updateLastMessage);
|
|
|
|
this.on('read', this.updateLastMessage);
|
|
|
|
this.on('sent', this.updateLastMessage);
|
|
|
|
this.on('sent', this.updateLastMessage);
|
|
|
|
this.on('expired', this.onExpired);
|
|
|
|
this.on('expired', this.onExpired);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updateLastMessage();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
isMe() {
|
|
|
|
isMe() {
|
|
|
@ -198,8 +200,8 @@
|
|
|
|
isSelected: this.isSelected,
|
|
|
|
isSelected: this.isSelected,
|
|
|
|
|
|
|
|
|
|
|
|
lastMessage: {
|
|
|
|
lastMessage: {
|
|
|
|
status: this.get('lastMessageStatus'),
|
|
|
|
status: this.lastMessageStatus,
|
|
|
|
text: this.get('lastMessage'),
|
|
|
|
text: this.lastMessage,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onClick: () => this.trigger('select', this),
|
|
|
|
onClick: () => this.trigger('select', this),
|
|
|
@ -899,6 +901,10 @@
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
async updateLastMessage() {
|
|
|
|
async updateLastMessage() {
|
|
|
|
|
|
|
|
if (!this.id) {
|
|
|
|
|
|
|
|
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 }
|
|
|
@ -907,26 +913,41 @@
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const lastMessage = messages.at(0);
|
|
|
|
const lastMessageModel = messages.at(0);
|
|
|
|
|
|
|
|
|
|
|
|
const lastMessageJSON = lastMessage ? lastMessage.toJSON() : null;
|
|
|
|
const lastMessageJSON = lastMessageModel
|
|
|
|
const lastMessageStatus = lastMessage
|
|
|
|
? lastMessageModel.toJSON()
|
|
|
|
? lastMessage.getMessagePropStatus()
|
|
|
|
: null;
|
|
|
|
|
|
|
|
const lastMessageStatusModel = lastMessageModel
|
|
|
|
|
|
|
|
? lastMessageModel.getMessagePropStatus()
|
|
|
|
: null;
|
|
|
|
: null;
|
|
|
|
const lastMessageUpdate = Conversation.createLastMessageUpdate({
|
|
|
|
const lastMessageUpdate = Conversation.createLastMessageUpdate({
|
|
|
|
currentLastMessageText: this.get('lastMessage') || null,
|
|
|
|
currentLastMessageText: this.get('lastMessage') || null,
|
|
|
|
currentTimestamp: this.get('timestamp') || null,
|
|
|
|
currentTimestamp: this.get('timestamp') || null,
|
|
|
|
lastMessage: lastMessageJSON,
|
|
|
|
lastMessage: lastMessageJSON,
|
|
|
|
lastMessageStatus,
|
|
|
|
lastMessageStatus: lastMessageStatusModel,
|
|
|
|
lastMessageNotificationText: lastMessage
|
|
|
|
lastMessageNotificationText: lastMessageModel
|
|
|
|
? lastMessage.getNotificationText()
|
|
|
|
? lastMessageModel.getNotificationText()
|
|
|
|
: null,
|
|
|
|
: null,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let hasChanged = false;
|
|
|
|
|
|
|
|
const { lastMessage, lastMessageStatus } = lastMessageUpdate;
|
|
|
|
|
|
|
|
lastMessageUpdate.lastMessage = null;
|
|
|
|
|
|
|
|
lastMessageUpdate.lastMessageStatus = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hasChanged = hasChanged || lastMessage !== this.lastMessage;
|
|
|
|
|
|
|
|
this.lastMessage = lastMessage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hasChanged = hasChanged || lastMessageStatus !== this.lastMessageStatus;
|
|
|
|
|
|
|
|
this.lastMessageStatus = lastMessageStatus;
|
|
|
|
|
|
|
|
|
|
|
|
this.set(lastMessageUpdate);
|
|
|
|
this.set(lastMessageUpdate);
|
|
|
|
|
|
|
|
|
|
|
|
if (this.hasChanged('lastMessage') || this.hasChanged('timestamp')) {
|
|
|
|
if (this.hasChanged()) {
|
|
|
|
this.save();
|
|
|
|
this.save();
|
|
|
|
|
|
|
|
} else if (hasChanged) {
|
|
|
|
|
|
|
|
this.trigger('change');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|