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
This commit is contained in:
Scott Nonnenberg 2017-09-06 18:19:11 -07:00 committed by GitHub
parent 4cba16cb61
commit 4009a0119e

View file

@ -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'));
},