mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Refactor contact rendering in message detail view
DRY // FREEBIE
This commit is contained in:
@@ -76,6 +76,12 @@
|
||||
this.render();
|
||||
});
|
||||
},
|
||||
renderContact: function(contact) {
|
||||
var v = new ContactView({
|
||||
model: contact,
|
||||
conflict: this.model.getKeyConflict(contact.id)
|
||||
}).render().$el.appendTo(this.$('.contacts'));
|
||||
},
|
||||
render: function() {
|
||||
this.$el.html(Mustache.render(this.template, {
|
||||
sent_at : moment(this.model.get('sent_at')).toString(),
|
||||
@@ -85,19 +91,11 @@
|
||||
this.view.render().$el.prependTo(this.$('.message-container'));
|
||||
|
||||
if (this.model.isOutgoing()) {
|
||||
this.conversation.contactCollection.each(function(contact) {
|
||||
var v = new ContactView({
|
||||
model: contact,
|
||||
conflict: this.model.getKeyConflict(contact.id)
|
||||
}).render().$el.appendTo(this.$('.contacts'));
|
||||
}.bind(this));
|
||||
this.conversation.contactCollection.each(this.renderContact.bind(this));
|
||||
} else {
|
||||
var number = this.model.get('source');
|
||||
var contact = this.conversation.contactCollection.get(number);
|
||||
var v = new ContactView({
|
||||
model: contact,
|
||||
conflict: this.model.getKeyConflict(number)
|
||||
}).render().$el.appendTo(this.$('.contacts'));
|
||||
this.renderContact(
|
||||
this.conversation.contactCollection.get(this.model.get('source'))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user