diff --git a/js/models/messages.js b/js/models/messages.js index 38d52210..bcb73964 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -73,6 +73,9 @@ } return this.get('body'); }, + isKeyChange: function() { + return this.get('type') === 'keychange'; + }, getNotificationText: function() { var description = this.getDescription(); if (description) { @@ -88,6 +91,10 @@ ) ); } + if (this.isKeyChange()) { + var conversation = this.getModelForKeyChange(); + return i18n('keychanged', conversation.getTitle()); + } return ''; }, @@ -145,12 +152,15 @@ }, getModelForKeyChange: function() { var id = this.get('key_changed'); - var c = ConversationController.get(id); - if (!c) { - c = ConversationController.create({ id: id, type: 'private' }); - c.fetch(); + if (!this.modelForKeyChange) { + var c = ConversationController.get(id); + if (!c) { + c = ConversationController.create({ id: id, type: 'private' }); + c.fetch(); + } + this.modelForKeyChange = c; } - return c; + return this.modelForKeyChange; }, isOutgoing: function() { return this.get('type') === 'outgoing'; diff --git a/js/views/message_view.js b/js/views/message_view.js index fab4d5a2..3ee0bd22 100644 --- a/js/views/message_view.js +++ b/js/views/message_view.js @@ -91,7 +91,7 @@ }, render_attributes: function() { return { - content: i18n('keychanged', this.conversation.getTitle()) + content: this.model.getNotificationText() }; }, verifyIdentity: function() {