diff --git a/js/background.js b/js/background.js index 2e76b29e..c0bd1173 100644 --- a/js/background.js +++ b/js/background.js @@ -35,9 +35,6 @@ // start a background worker for ecc textsecure.protocol_wrapper.startWorker(); - // load the initial set of conversations into memory - ConversationController.updateInbox(); - extension.onLaunched(function() { console.log('extension launched'); storage.onready(function() { diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 31988245..71be1ceb 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -74,7 +74,7 @@ }); }, updateInbox: function() { - conversations.fetchActive(); + return conversations.fetchActive(); } }; })(); diff --git a/js/index.js b/js/index.js index 18d7b1ab..95dca20b 100644 --- a/js/index.js +++ b/js/index.js @@ -20,21 +20,22 @@ function render() { extension.windows.getBackground(function(bg) { extension.windows.getCurrent(function(appWindow) { - try { - if (view) { view.remove(); } - var $body = bg.$('body',document).empty(); - view = new bg.Whisper.InboxView({appWindow: appWindow}); - view.$el.prependTo($body); - window.openConversation = function(conversation) { - if (conversation) { - view.openConversation(null, conversation); - } - }; - openConversation(bg.getOpenConversation()); - } catch (e) { - logError(e); - } - + bg.ConversationController.updateInbox().then(function() { + try { + if (view) { view.remove(); } + var $body = bg.$('body',document).empty(); + view = new bg.Whisper.InboxView({appWindow: appWindow}); + view.$el.prependTo($body); + window.openConversation = function(conversation) { + if (conversation) { + view.openConversation(null, conversation); + } + }; + openConversation(bg.getOpenConversation()); + } catch (e) { + logError(e); + } + }); }); }); } diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 6fb37932..4883d982 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -74,7 +74,7 @@ }).render(); this.inboxListView.listenTo(inboxCollection, - 'change:active_at', + 'add change:active_at', this.inboxListView.onChangeActiveAt); this.searchView = new Whisper.ConversationSearchView({