diff --git a/js/background.js b/js/background.js index ccbf8c62..f9200d20 100644 --- a/js/background.js +++ b/js/background.js @@ -137,13 +137,13 @@ var message = initIncomingMessage(envelope.source, envelope.timestamp.toNumber()); if (e.name === 'IncomingIdentityKeyError') { message.save({ errors : [e] }).then(function() { - extension.trigger('updateInbox'); + updateInbox(); notifyConversation(message); }); return; } else if (e.message !== 'Bad MAC') { message.save({ errors : [ _.pick(e, ['name', 'message'])]}).then(function() { - extension.trigger('updateInbox'); + updateInbox(); notifyConversation(message); }); return; diff --git a/js/models/conversations.js b/js/models/conversations.js index cb40490f..be01e51f 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -84,7 +84,7 @@ timestamp : now, lastMessage : body }).then(function() { - extension.trigger('updateInbox'); // inbox fetch + updateInbox(); }); var sendFunc; @@ -108,7 +108,7 @@ }); if (keyErrors.length) { message.save({ errors : keyErrors }).then(function() { - extension.trigger('updateInbox'); // notify frontend listeners + updateInbox(); }); } else { if (!(errors instanceof Array)) { @@ -188,7 +188,7 @@ _.each(models, function(message) { message.destroy(); }); this.archive(); return this.save().then(function() { - extension.trigger('updateInbox'); + updateInbox(); }); }, diff --git a/js/models/messages.js b/js/models/messages.js index 9a85af4d..343c2806 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -218,7 +218,7 @@ conversation.save().then(function() { message.save().then(function() { - extension.trigger('updateInbox'); // inbox fetch + updateInbox(); if (message.isIncoming()) { notifyConversation(message); } else { diff --git a/js/panel_controller.js b/js/panel_controller.js index 188ed8a2..930e0774 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -41,15 +41,14 @@ } }); - function updateInbox() { + window.updateInbox = function() { conversations.fetchActive().then(function() { inbox.reset(conversations.filter(function(model) { return model.get('active_at'); })); }); - } + }; - extension.on('updateInbox', updateInbox); updateInbox(); setUnreadCount(storage.get("unreadCount", 0));