Skip to content

Commit

Permalink
Tweak key change advisory insertion
Browse files Browse the repository at this point in the history
Let received_at be the current time for keychanges. This avoids them
being inserted in the wrong place in the thread.

Use the newmessage event to trigger frontend listeners to add them to
the conversation view if it is open.
  • Loading branch information
liliakai committed Jan 26, 2017
1 parent a623f90 commit 6253269
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/models/conversations.js
Expand Up @@ -51,14 +51,16 @@
},

addKeyChange: function(id) {
var message = this.messageCollection.add({
var timestamp = Date.now();
var message = new Whisper.Message({
conversationId : this.id,
type : 'keychange',
sent_at : this.get('timestamp'),
received_at : this.get('timestamp'),
received_at : timestamp,
key_changed : id
});
message.save();
this.set({ lastMessage: message.getNotificationText() });
message.save().then(this.trigger.bind(this,'newmessage', message));
},

onReadMessage: function(message) {
Expand Down

0 comments on commit 6253269

Please sign in to comment.