Remove reader events when plugin is disabled
This commit is contained in:
parent
96652ea9e8
commit
78fe68164f
1 changed files with 12 additions and 2 deletions
|
@ -1229,6 +1229,12 @@ class Reader {
|
|||
}
|
||||
this._setSidebarState();
|
||||
}, 500);
|
||||
|
||||
Zotero.Plugins.addObserver({
|
||||
shutdown: ({ id: pluginID }) => {
|
||||
this._unregisterEventListenerByPluginID(pluginID);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_dispatchEvent(event) {
|
||||
|
@ -1269,13 +1275,17 @@ class Reader {
|
|||
* });
|
||||
* });
|
||||
*/
|
||||
registerEventListener(type, handler) {
|
||||
this._registeredListeners.push({ type, handler });
|
||||
registerEventListener(type, handler, pluginID = undefined) {
|
||||
this._registeredListeners.push({ pluginID, type, handler });
|
||||
}
|
||||
|
||||
unregisterEventListener(type, handler) {
|
||||
this._registeredListeners = this._registeredListeners.filter(x => x.type === type && x.handler === handler);
|
||||
}
|
||||
|
||||
_unregisterEventListenerByPluginID(pluginID) {
|
||||
this._registeredListeners = this._registeredListeners.filter(x => x.pluginID !== pluginID);
|
||||
}
|
||||
|
||||
getSidebarWidth() {
|
||||
return this._sidebarWidth;
|
||||
|
|
Loading…
Reference in a new issue