From 4418be19d4c77721b72b79c08e0529ffa5f8bdd2 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 12 Nov 2015 12:08:29 -0800 Subject: [PATCH] Update conversation header avatar if it changes // FREEBIE --- js/views/conversation_view.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 443142da..d5860269 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -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;