diff --git a/libs/package.json b/libs/package.json index b1942208c..1b70e5ab5 100644 --- a/libs/package.json +++ b/libs/package.json @@ -1,6 +1,6 @@ { "name": "@logseq/libs", - "version": "0.0.2", + "version": "0.0.3", "description": "Logseq SDK libraries", "main": "dist/lsplugin.user.js", "typings": "index.d.ts", diff --git a/libs/src/LSPlugin.user.ts b/libs/src/LSPlugin.user.ts index 548defbeb..760c1ae13 100644 --- a/libs/src/LSPlugin.user.ts +++ b/libs/src/LSPlugin.user.ts @@ -402,7 +402,6 @@ export class LSPluginUser console.warn(e) } - callback && callback.call(this, baseInfo) } catch (e) { console.error(`${this._debugTag} [Ready Error]`, e) @@ -575,13 +574,15 @@ export class LSPluginUser const handler = args[0] caller[f](type, handler) - if (isOff) { - return () => { - caller.off(type, handler) + if (!isOff) { + that.App._installPluginHook(pid, type) + } + + return () => { + caller.off(type, handler) + if (!caller.listenerCount(type)) { that.App._uninstallPluginHook(pid, type) } - } else { - return that.App._installPluginHook(pid, type) } } }