diff --git a/js/chromium.js b/js/chromium.js index 98001fdc0..58860b1b2 100644 --- a/js/chromium.js +++ b/js/chromium.js @@ -115,7 +115,7 @@ } }, - beforeUnload: function(callback) { + onSuspend: function(callback) { if (chrome.runtime) { chrome.runtime.onSuspend.addListener(callback); } else { diff --git a/js/panel_controller.js b/js/panel_controller.js index 3e58bccc8..d1f9239b1 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -63,8 +63,8 @@ inboxFocused = true; }); - // close the panel if background.html is refreshed - extension.windows.beforeUnload(function() { + // close the inbox if background.html is refreshed + extension.windows.onSuspend(function() { // TODO: reattach after reload instead of closing. extension.windows.remove(inboxWindowId); }); diff --git a/js/views/conversation_list_item_view.js b/js/views/conversation_list_item_view.js index 3597a86e4..c501625c5 100644 --- a/js/views/conversation_list_item_view.js +++ b/js/views/conversation_list_item_view.js @@ -19,9 +19,7 @@ this.listenTo(this.model, 'change', this.render); // auto update this.listenTo(this.model, 'destroy', this.remove); // auto update this.listenTo(this.model, 'opened', this.markSelected); // auto update - extension.windows.beforeUnload(function() { - this.stopListening(); - }.bind(this)); + extension.windows.onClosed(this.stopListening.bind(this)); }, markSelected: function() { diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 90e4c4a38..55d710fa0 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -116,7 +116,7 @@ new SocketView().render().$el.appendTo(this.$('.socket-status')); - extension.windows.beforeUnload(function() { + extension.windows.onClosed(function() { this.inboxListView.stopListening(); }.bind(this)); },