From 4009a0119ebd2071be2edf5d73fd500ee130f42c Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 6 Sep 2017 18:19:11 -0700 Subject: [PATCH] MessageView: Handle change of color to null, call getColor() (#1438) When we relied on the actual value of the color property to be supplied to the updateColor change event listener, sometimes it would be null. Then the conversation bubbles would have no color at all, making the text hard to read. FREEBIE --- js/views/message_view.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/views/message_view.js b/js/views/message_view.js index 73ba07cb0..f6e5043f9 100644 --- a/js/views/message_view.js +++ b/js/views/message_view.js @@ -365,15 +365,18 @@ return this; }, - updateColor: function(model, color) { + updateColor: function() { var bubble = this.$('.bubble'); - bubble.removeClass(Whisper.Conversation.COLORS); + + // this.contact is known to be non-null if we're registered for color changes + var color = this.contact.getColor(); if (color) { + bubble.removeClass(Whisper.Conversation.COLORS); bubble.addClass(color); } this.avatarView = new (Whisper.View.extend({ templateName: 'avatar', - render_attributes: { avatar: model.getAvatar() } + render_attributes: { avatar: this.model.getAvatar() } }))(); this.$('.avatar').replaceWith(this.avatarView.render().$('.avatar')); },