|
|
@ -27,16 +27,21 @@
|
|
|
|
window.addEventListener('resize', this.resize.bind(this));
|
|
|
|
window.addEventListener('resize', this.resize.bind(this));
|
|
|
|
this.conversations = new Whisper.ConversationCollection();
|
|
|
|
this.conversations = new Whisper.ConversationCollection();
|
|
|
|
|
|
|
|
|
|
|
|
new Whisper.ConversationListView({el: $('#contacts'), collection: Whisper.Conversations});
|
|
|
|
new Whisper.ConversationListView({
|
|
|
|
Whisper.Conversations.fetch({reset: true}).then(function() {
|
|
|
|
el : $('#contacts'),
|
|
|
|
if (Whisper.Conversations.length) {
|
|
|
|
collection : this.conversations
|
|
|
|
Whisper.Conversations.at(0).trigger('render');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.conversations.fetch({reset: true}).then(function() {
|
|
|
|
|
|
|
|
if (this.conversations.length) {
|
|
|
|
|
|
|
|
this.conversations.at(0).trigger('render');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
|
|
|
|
extension.onMessage('message', function(message) {
|
|
|
|
extension.onMessage('message', function(message) {
|
|
|
|
Whisper.Conversations.fetch({id: message.conversationId}).then(function() {
|
|
|
|
this.conversations.fetch({id: message.conversationId}).then(function() {
|
|
|
|
Whisper.Conversations.get(message.conversationId).fetchMessages();
|
|
|
|
this.conversations.get(message.conversationId).fetchMessages();
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -44,18 +49,21 @@
|
|
|
|
'click #new-message': 'new_message',
|
|
|
|
'click #new-message': 'new_message',
|
|
|
|
'click #new-group': 'new_group'
|
|
|
|
'click #new-group': 'new_group'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
new_message: function (e) {
|
|
|
|
new_message: function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
$('.conversation').hide().trigger('close'); // detach any existing conversation views
|
|
|
|
$('.conversation').hide().trigger('close'); // detach any existing conversation views
|
|
|
|
this.view = new Whisper.NewConversationView();
|
|
|
|
this.view = new Whisper.NewConversationView({
|
|
|
|
//todo: less new
|
|
|
|
collection: this.conversations
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.setContent(this.view.render().$el.show());
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
new_group: function (e) {
|
|
|
|
new_group: function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
$('.conversation').trigger('close'); // detach any existing conversation views
|
|
|
|
$('.conversation').trigger('close'); // detach any existing conversation views
|
|
|
|
new Whisper.NewGroupView();
|
|
|
|
var view = new Whisper.NewGroupView({
|
|
|
|
|
|
|
|
collection: this.conversations
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.setContent(view.render().$el.show());
|
|
|
|
},
|
|
|
|
},
|
|
|
|
resize: function (e) {
|
|
|
|
resize: function (e) {
|
|
|
|
var windowheight = window.innerHeight,
|
|
|
|
var windowheight = window.innerHeight,
|
|
|
|