diff --git a/conversation.html b/conversation.html index c5016fab..ed66e5f6 100644 --- a/conversation.html +++ b/conversation.html @@ -102,11 +102,13 @@
{{ #contacts }} - - {{ name }}
- {{ #conflict }} - - {{ /conflict }} +
+ + {{ name }}
+ {{ #conflict }} + + {{ /conflict }} + {{ /contacts }} diff --git a/js/models/conversations.js b/js/models/conversations.js index 167ad8c4..a7f08441 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -34,6 +34,7 @@ initialize: function() { this.messageCollection = new Whisper.MessageCollection(); + this.contactCollection = new Whisper.ConversationCollection(); }, validate: function(attributes, options) { @@ -143,6 +144,20 @@ return this.messageCollection.fetchConversation(this.id, options); }, + fetchContacts: function(options) { + if (this.isPrivate()) { + this.contactCollection.reset([this]); + } else { + this.contactCollection.reset( + this.get('members').map(function(number) { + var c = this.collection.add({id: number, type: 'private'}); + c.fetch(); + return c; + }.bind(this)) + ); + } + }, + archive: function() { this.unset('active_at'); }, @@ -165,6 +180,9 @@ } else { return ''; } + }, + isPrivate: function() { + return this.get('type') === 'private'; } }); diff --git a/js/models/messages.js b/js/models/messages.js index a375423c..9f972235 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -40,6 +40,9 @@ }, isGroupUpdate: function() { return !!(this.get('group_update')); + }, + isIncoming: function() { + return this.get('type') === 'incoming'; } }); diff --git a/js/panel_controller.js b/js/panel_controller.js index fbe77812..155094ad 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -43,7 +43,9 @@ window.openConversation = function openConversation (modelId) { var conversation = conversations.add({id: modelId}); - conversation.fetch(); + conversation.fetch().then(function() { + conversation.fetchContacts(); + }); conversation.fetchMessages(); var windowId = windowMap.windowIdFrom(modelId); diff --git a/js/views/message_detail_view.js b/js/views/message_detail_view.js index e912f593..f51cacc0 100644 --- a/js/views/message_detail_view.js +++ b/js/views/message_detail_view.js @@ -37,10 +37,12 @@ sent_at: moment(this.model.get('sent_at')).toString(), received_at: moment(this.model.get('received_at')).toString(), tofrom: this.model.isIncoming() ? 'From' : 'To', - contacts: { - name : this.conversation.getTitle(), - avatar : this.conversation.get('avatar') - } + contacts: this.conversation.contactCollection.map(function(contact) { + return { + name : contact.getTitle(), + avatar : contact.get('avatar'), + }; + }.bind(this)) })); this.view.render().$el.prependTo(this.$el.find('.message-container')); }