mirror of
https://github.com/zotero/zotero.git
synced 2026-10-09 03:18:01 +00:00
Unregister Zotero_Tabs observers when window is unloaded
This commit is contained in:
parent
7b56a3eefe
commit
81d9ed77e9
1 changed files with 7 additions and 2 deletions
|
|
@ -85,10 +85,10 @@ var Zotero_Tabs = new function () {
|
|||
this._tabsMenuIgnoreMouseover = false;
|
||||
|
||||
// Keep track of item modifications to update the title
|
||||
Zotero.Notifier.registerObserver(this, ['item'], 'tabs');
|
||||
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'tabs');
|
||||
|
||||
// Update the title when pref of title format is changed
|
||||
Zotero.Prefs.registerObserver('tabs.title.reader', async () => {
|
||||
this._prefsObserverID = Zotero.Prefs.registerObserver('tabs.title.reader', async () => {
|
||||
for (let tab of this._tabs) {
|
||||
if (!tab.data.itemID) continue;
|
||||
let item = Zotero.Items.get(tab.data.itemID);
|
||||
|
|
@ -96,6 +96,11 @@ var Zotero_Tabs = new function () {
|
|||
this.rename(tab.id, title);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('unload', () => {
|
||||
Zotero.Notifier.unregisterObserver(this._notifierID);
|
||||
Zotero.Prefs.unregisterObserver(this._prefsObserverID);
|
||||
});
|
||||
|
||||
this._unloadInterval = setInterval(() => {
|
||||
this.unloadUnusedTabs();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue