Render group members in the message detail view
This requires that we fetch contact info when opening a conversation so that's available for rendering contact names and avatars.
This commit is contained in:
parent
2277b41639
commit
c08c29bd4a
5 changed files with 37 additions and 10 deletions
|
@ -102,11 +102,13 @@
|
||||||
<td>
|
<td>
|
||||||
<div class='contacts'>
|
<div class='contacts'>
|
||||||
{{ #contacts }}
|
{{ #contacts }}
|
||||||
|
<div>
|
||||||
<img class='avatar' src='{{ avatar }}'>
|
<img class='avatar' src='{{ avatar }}'>
|
||||||
<span class='name'>{{ name }}</div>
|
<span class='name'>{{ name }}</div>
|
||||||
{{ #conflict }}
|
{{ #conflict }}
|
||||||
<button class='resolve'>Key Conflict</button>
|
<button class='resolve'>Key Conflict</button>
|
||||||
{{ /conflict }}
|
{{ /conflict }}
|
||||||
|
</div>
|
||||||
{{ /contacts }}
|
{{ /contacts }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.messageCollection = new Whisper.MessageCollection();
|
this.messageCollection = new Whisper.MessageCollection();
|
||||||
|
this.contactCollection = new Whisper.ConversationCollection();
|
||||||
},
|
},
|
||||||
|
|
||||||
validate: function(attributes, options) {
|
validate: function(attributes, options) {
|
||||||
|
@ -143,6 +144,20 @@
|
||||||
return this.messageCollection.fetchConversation(this.id, options);
|
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() {
|
archive: function() {
|
||||||
this.unset('active_at');
|
this.unset('active_at');
|
||||||
},
|
},
|
||||||
|
@ -165,6 +180,9 @@
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isPrivate: function() {
|
||||||
|
return this.get('type') === 'private';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
},
|
},
|
||||||
isGroupUpdate: function() {
|
isGroupUpdate: function() {
|
||||||
return !!(this.get('group_update'));
|
return !!(this.get('group_update'));
|
||||||
|
},
|
||||||
|
isIncoming: function() {
|
||||||
|
return this.get('type') === 'incoming';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,9 @@
|
||||||
|
|
||||||
window.openConversation = function openConversation (modelId) {
|
window.openConversation = function openConversation (modelId) {
|
||||||
var conversation = conversations.add({id: modelId});
|
var conversation = conversations.add({id: modelId});
|
||||||
conversation.fetch();
|
conversation.fetch().then(function() {
|
||||||
|
conversation.fetchContacts();
|
||||||
|
});
|
||||||
conversation.fetchMessages();
|
conversation.fetchMessages();
|
||||||
|
|
||||||
var windowId = windowMap.windowIdFrom(modelId);
|
var windowId = windowMap.windowIdFrom(modelId);
|
||||||
|
|
|
@ -37,10 +37,12 @@
|
||||||
sent_at: moment(this.model.get('sent_at')).toString(),
|
sent_at: moment(this.model.get('sent_at')).toString(),
|
||||||
received_at: moment(this.model.get('received_at')).toString(),
|
received_at: moment(this.model.get('received_at')).toString(),
|
||||||
tofrom: this.model.isIncoming() ? 'From' : 'To',
|
tofrom: this.model.isIncoming() ? 'From' : 'To',
|
||||||
contacts: {
|
contacts: this.conversation.contactCollection.map(function(contact) {
|
||||||
name : this.conversation.getTitle(),
|
return {
|
||||||
avatar : this.conversation.get('avatar')
|
name : contact.getTitle(),
|
||||||
}
|
avatar : contact.get('avatar'),
|
||||||
|
};
|
||||||
|
}.bind(this))
|
||||||
}));
|
}));
|
||||||
this.view.render().$el.prependTo(this.$el.find('.message-container'));
|
this.view.render().$el.prependTo(this.$el.find('.message-container'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue