From d89e3ccdc49892b46a48cfaa66ee73aa269af689 Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 14 Sep 2015 13:47:47 -0700 Subject: [PATCH] Don't fetch messages from the background Only fetch them from a frontend view. If the conversation is not open, we don't need to load the messages, and if we do load them, they will render before we've done the initial contact info loading (as implemented in 74e96ce). Fixes #344 // FREEBIE --- js/background.js | 2 +- js/panel_controller.js | 2 +- js/views/conversation_view.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/background.js b/js/background.js index 2dcf141bb32..d4f795002c6 100644 --- a/js/background.js +++ b/js/background.js @@ -155,7 +155,7 @@ function updateConversation(conversationId) { var conversation = ConversationController.get(conversationId); if (conversation) { - conversation.fetchMessages(); + conversation.trigger('newmessages'); } } diff --git a/js/panel_controller.js b/js/panel_controller.js index b8b4b1ab32c..2f299e0176a 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -87,7 +87,7 @@ conversation.fetch(); } if (inboxOpened) { - conversation.fetchMessages(); + conversation.trigger('newmessages'); extension.windows.drawAttention(inboxWindowId); } else if (Whisper.Notifications.isEnabled()) { var sender = ConversationController.create({id: message.get('source')}); diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 78454a323a4..07a7add49d7 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -23,6 +23,7 @@ initialize: function(options) { this.listenTo(this.model, 'destroy', this.stopListening); this.listenTo(this.model, 'change:name', this.updateTitle); + this.listenTo(this.model, 'newmessages', this.fetchMessages); this.render(); @@ -79,6 +80,9 @@ 'select .entry': 'messageDetail', 'force-resize': 'forceUpdateMessageFieldSize' }, + fetchMessages: function() { + this.model.fetchMessages(); + }, viewMembers: function() { var view = new Whisper.GroupMemberList({ model: this.model });