MessageView: Only re-render on change of key conversation fields

This commit is contained in:
Scott Nonnenberg 2018-08-31 13:39:56 -07:00
parent 0d6c3c0bce
commit ea8e76d9de

View file

@ -99,17 +99,24 @@
this.listenTo(this.model, 'change', update); this.listenTo(this.model, 'change', update);
this.listenTo(this.model, 'expired', update); this.listenTo(this.model, 'expired', update);
const applicableConversationChanges =
'change:color change:name change:number change:profileName change:profileAvatar';
this.conversation = this.model.getConversation(); this.conversation = this.model.getConversation();
this.listenTo(this.conversation, 'change', update); this.listenTo(this.conversation, applicableConversationChanges, update);
this.fromContact = this.model.getIncomingContact(); this.fromContact = this.model.getIncomingContact();
if (this.fromContact) { if (this.fromContact) {
this.listenTo(this.fromContact, 'change', update); this.listenTo(this.fromContact, applicableConversationChanges, update);
} }
this.quotedContact = this.model.getQuoteContact(); this.quotedContact = this.model.getQuoteContact();
if (this.quotedContact) { if (this.quotedContact) {
this.listenTo(this.quotedContact, 'change', update); this.listenTo(
this.quotedContact,
applicableConversationChanges,
update
);
} }
this.$el.append(this.childView.el); this.$el.append(this.childView.el);