Move key change advisory content to the model

Return this content from a helper method so it can be used to populate
the last message on conversations.
This commit is contained in:
lilia 2017-01-22 20:20:53 -08:00
parent 260f50c104
commit a623f909f2
2 changed files with 16 additions and 6 deletions

View file

@ -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';

View file

@ -91,7 +91,7 @@
},
render_attributes: function() {
return {
content: i18n('keychanged', this.conversation.getTitle())
content: this.model.getNotificationText()
};
},
verifyIdentity: function() {