Refactor contact rendering in message detail view
DRY // FREEBIE
This commit is contained in:
parent
b8536679b3
commit
0f8aff12c5
1 changed files with 10 additions and 12 deletions
|
@ -76,6 +76,12 @@
|
||||||
this.render();
|
this.render();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
renderContact: function(contact) {
|
||||||
|
var v = new ContactView({
|
||||||
|
model: contact,
|
||||||
|
conflict: this.model.getKeyConflict(contact.id)
|
||||||
|
}).render().$el.appendTo(this.$('.contacts'));
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(Mustache.render(this.template, {
|
this.$el.html(Mustache.render(this.template, {
|
||||||
sent_at : moment(this.model.get('sent_at')).toString(),
|
sent_at : moment(this.model.get('sent_at')).toString(),
|
||||||
|
@ -85,19 +91,11 @@
|
||||||
this.view.render().$el.prependTo(this.$('.message-container'));
|
this.view.render().$el.prependTo(this.$('.message-container'));
|
||||||
|
|
||||||
if (this.model.isOutgoing()) {
|
if (this.model.isOutgoing()) {
|
||||||
this.conversation.contactCollection.each(function(contact) {
|
this.conversation.contactCollection.each(this.renderContact.bind(this));
|
||||||
var v = new ContactView({
|
|
||||||
model: contact,
|
|
||||||
conflict: this.model.getKeyConflict(contact.id)
|
|
||||||
}).render().$el.appendTo(this.$('.contacts'));
|
|
||||||
}.bind(this));
|
|
||||||
} else {
|
} else {
|
||||||
var number = this.model.get('source');
|
this.renderContact(
|
||||||
var contact = this.conversation.contactCollection.get(number);
|
this.conversation.contactCollection.get(this.model.get('source'))
|
||||||
var v = new ContactView({
|
);
|
||||||
model: contact,
|
|
||||||
conflict: this.model.getKeyConflict(number)
|
|
||||||
}).render().$el.appendTo(this.$('.contacts'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue