Use onClosed instead of onSuspend
Renames extension.windows.beforeUnload to onSuspend, to match the underlying chrome api call. onClosed fires when the frontend app window is closed, while onSuspend fires when the background page is closed or refreshed (which amounts to an app restart). Frontend views are initialized iff the inbox window is opened, and so should always be listening to onClosed in order to know when they are no longer needed. // FREEBIE
This commit is contained in:
parent
038e263023
commit
f0dcf44b9f
4 changed files with 5 additions and 7 deletions
|
@ -115,7 +115,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
beforeUnload: function(callback) {
|
||||
onSuspend: function(callback) {
|
||||
if (chrome.runtime) {
|
||||
chrome.runtime.onSuspend.addListener(callback);
|
||||
} else {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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));
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue