fix(plugin): return clear handle for hooks api

pull/5152/head
charlie 2022-04-24 10:49:50 +08:00 committed by Andelf
parent 6e6aa5819a
commit f4bb7bfa9b
2 changed files with 8 additions and 7 deletions

View File

@ -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",

View File

@ -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)
}
}
}