diff --git a/js/background.js b/js/background.js index 4bc17d33218..904e7a9eebc 100644 --- a/js/background.js +++ b/js/background.js @@ -194,6 +194,7 @@ conversation.save().then(function() { message.save().then(function() { extension.trigger('message', message); // notify frontend listeners + openConversation(conversation.id); }); }); }); diff --git a/js/conversation_panel.js b/js/conversation_panel.js index a79dd7a1561..e3d341288fa 100644 --- a/js/conversation_panel.js +++ b/js/conversation_panel.js @@ -26,6 +26,7 @@ new Whisper.ConversationView({ model: conversation }).render().$el.prependTo($('body')); + window.conversation = conversation; }); }; diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 74fe4f8afd1..9e3b6b2dd44 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -42,6 +42,11 @@ if (this.model.id) { this.model.fetchMessages({reset: true}); } + + extension.on('message', function() { + this.model.fetchMessages(); + }.bind(this)); + window.addEventListener('resize', this.view.resize.bind(this.view)); }, diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index d7d346c65e6..288bfc94d07 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -38,12 +38,11 @@ this.$el.addClass('loading'); this.conversations.fetchActive({reset: true}).then(function() { this.$el.removeClass('loading'); + window.conversations = this.conversations; }.bind(this)); - extension.on('message', function(message) { - this.conversations.fetch({id: message.conversationId}).then(function() { - this.conversations.get(message.conversationId).fetchMessages(); - }.bind(this)); + extension.on('message', function() { + this.conversations.fetchActive({reset: true}); }.bind(this)); window.addEventListener('resize', this.inbox.resize.bind(this.inbox)); },