Bring lastMessage and lastMessageStatus back to conversation

This commit is contained in:
Scott Nonnenberg 2019-02-27 18:15:24 -08:00
parent dcd16775c3
commit 812f895e12
2 changed files with 11 additions and 20 deletions

View file

@ -224,7 +224,13 @@
this._initialFetchComplete = true;
await Promise.all(
conversations.map(conversation => conversation.updateLastMessage())
conversations.map(conversation => {
if (!conversation.get('lastMessage')) {
return conversation.updateLastMessage();
}
return null;
})
);
window.log.info('ConversationController: done with initial fetch');
} catch (error) {

View file

@ -135,8 +135,6 @@
this.unset('unidentifiedDeliveryUnrestricted');
this.unset('hasFetchedProfile');
this.unset('tokens');
this.unset('lastMessage');
this.unset('lastMessageStatus');
this.typingRefreshTimer = null;
this.typingPauseTimer = null;
@ -323,8 +321,8 @@
isTyping: typingKeys.length > 0,
lastMessage: {
status: this.lastMessageStatus,
text: this.lastMessage,
status: this.get('lastMessageStatus'),
text: this.get('lastMessage'),
},
onClick: () => this.trigger('select', this),
@ -879,10 +877,10 @@
});
const message = this.addSingleMessage(messageWithSchema);
this.lastMessage = message.getNotificationText();
this.lastMessageStatus = 'sending';
this.set({
lastMessage: message.getNotificationText(),
lastMessageStatus: 'sending',
active_at: now,
timestamp: now,
});
@ -1154,17 +1152,6 @@
: null,
});
let hasChanged = false;
const { lastMessage, lastMessageStatus } = lastMessageUpdate;
delete lastMessageUpdate.lastMessage;
delete lastMessageUpdate.lastMessageStatus;
hasChanged = hasChanged || lastMessage !== this.lastMessage;
this.lastMessage = lastMessage;
hasChanged = hasChanged || lastMessageStatus !== this.lastMessageStatus;
this.lastMessageStatus = lastMessageStatus;
// 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.
this.changed = {};
@ -1174,8 +1161,6 @@
await window.Signal.Data.updateConversation(this.id, this.attributes, {
Conversation: Whisper.Conversation,
});
} else if (hasChanged) {
this.trigger('change');
}
},