Update conversation header avatar if it changes

// FREEBIE
This commit is contained in:
lilia 2015-11-12 12:08:29 -08:00
parent a8e02a94be
commit 4418be19d4

View file

@ -23,6 +23,7 @@
},
initialize: function(options) {
this.listenTo(this.model, 'destroy', this.stopListening);
this.listenTo(this.model, 'change:avatar', this.updateAvatar);
this.listenTo(this.model, 'change:name', this.updateTitle);
this.listenTo(this.model, 'newmessage', this.addMessage);
this.listenTo(this.model, 'change:unreadCount', this.onUnread);
@ -221,6 +222,14 @@
this.$('.conversation-title').text(this.model.getTitle());
},
updateAvatar: function() {
var avatarView = new (Whisper.View.extend({
templateName: 'avatar',
render_attributes: { avatar: this.model.getAvatar() }
}))();
this.$('.conversation-header .avatar').replaceWith(avatarView.render().$('.avatar'));
},
updateMessageFieldSize: function (event) {
var keyCode = event.which || event.keyCode;