Close all tabs and unregister tabs observer when destroying main window

#2005
This commit is contained in:
Martynas Bagdonas 2021-03-17 17:53:16 +02:00
parent bf84e16002
commit 1ede4240e0
3 changed files with 11 additions and 1 deletions

View file

@ -50,7 +50,7 @@ const ZoteroStandalone = new function() {
}
this.switchMenuType('library');
Zotero.Notifier.registerObserver(
this._notifierID = Zotero.Notifier.registerObserver(
{
notify: async (action, type, ids, extraData) => {
if (action == 'select') {
@ -586,6 +586,7 @@ const ZoteroStandalone = new function() {
* Called before standalone window is closed
*/
this.onUnload = function() {
Zotero.Notifier.unregisterObserver(this._notifierID);
ZoteroPane.destroy();
}
}

View file

@ -169,6 +169,13 @@ var Zotero_Tabs = new function () {
}*/
};
/**
* Close all tabs except the first one
*/
this.closeAll = function () {
this._tabs.slice(1).map(tab => this.close(tab.id));
};
/**
* Move a tab to the specified index
*

View file

@ -370,6 +370,8 @@ var ZoteroPane = new function()
if(this.itemsView) this.itemsView.unregister();
observerService.removeObserver(_reloadObserver, "zotero-reloaded");
Zotero_Tabs.closeAll();
}
/**