Stop re-rendering attachments on delivery receipt
Only re-render a message if the body changed. Re-render only the delivery receipt checkmark if the delivered property changes. Fix a bug where attachments flash in and out of existance when a delivery receipt arrives.
This commit is contained in:
parent
dfe7813e7f
commit
99787753a8
1 changed files with 8 additions and 2 deletions
|
@ -35,9 +35,16 @@
|
|||
var ContentMessageView = Whisper.View.extend({
|
||||
tagName: 'div',
|
||||
template: $('#message').html(),
|
||||
initialize: function() {
|
||||
this.listenTo(this.model, 'change:body', this.render);
|
||||
this.listenTo(this.model, 'change:delivered', this.renderDelivered);
|
||||
},
|
||||
className: function() {
|
||||
if (this.model.get('delivered')) { return 'delivered'; }
|
||||
},
|
||||
renderDelivered: function() {
|
||||
if (this.model.get('delivered')) { this.$el.addClass('delivered'); }
|
||||
},
|
||||
render: function() {
|
||||
this.$el.html(
|
||||
Mustache.render(this.template, {
|
||||
|
@ -47,7 +54,7 @@
|
|||
})
|
||||
);
|
||||
|
||||
if (this.model.get('delivered')) { this.$el.addClass('delivered'); }
|
||||
this.renderDelivered();
|
||||
|
||||
this.$el.find('.attachments').append(
|
||||
this.model.get('attachments').map(function(attachment) {
|
||||
|
@ -85,7 +92,6 @@
|
|||
}
|
||||
this.$el.append(this.view.el);
|
||||
|
||||
this.listenTo(this.model, 'change', this.render); // auto update
|
||||
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
||||
},
|
||||
events: {
|
||||
|
|
Loading…
Reference in a new issue