Fix sorting on incoming key conflicts
// FREEBIE
This commit is contained in:
parent
07a0463b65
commit
8fe00f79b2
1 changed files with 8 additions and 1 deletions
|
@ -217,10 +217,17 @@
|
||||||
var message = initIncomingMessage(envelope.source, envelope.timestamp.toNumber());
|
var message = initIncomingMessage(envelope.source, envelope.timestamp.toNumber());
|
||||||
message.saveErrors(e).then(function() {
|
message.saveErrors(e).then(function() {
|
||||||
ConversationController.findOrCreatePrivateById(message.get('conversationId')).then(function(conversation) {
|
ConversationController.findOrCreatePrivateById(message.get('conversationId')).then(function(conversation) {
|
||||||
conversation.save({
|
conversation.set({
|
||||||
active_at: Date.now(),
|
active_at: Date.now(),
|
||||||
unreadCount: conversation.get('unreadCount') + 1
|
unreadCount: conversation.get('unreadCount') + 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var conversation_timestamp = conversation.get('timestamp');
|
||||||
|
var message_timestamp = message.get('timestamp');
|
||||||
|
if (!conversation_timestamp || message_timestamp > conversation_timestamp) {
|
||||||
|
conversation.set({ timestamp: message.get('sent_at') });
|
||||||
|
}
|
||||||
|
conversation.save();
|
||||||
conversation.trigger('newmessage', message);
|
conversation.trigger('newmessage', message);
|
||||||
conversation.notify(message);
|
conversation.notify(message);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue