mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 14:14:55 +00:00
Update libs/src/LSPlugin.user.ts
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
@@ -586,15 +586,21 @@ export class LSPluginUser
|
||||
const handler = args[0]
|
||||
caller[f](type, handler)
|
||||
|
||||
if (!isOff) {
|
||||
that.App._installPluginHook(pid, type)
|
||||
}
|
||||
const unlisten = () => {
|
||||
caller.off(type, handler)
|
||||
if (!caller.listenerCount(type)) {
|
||||
that.App._uninstallPluginHook(pid, type)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOff) {
|
||||
that.App._installPluginHook(pid, type)
|
||||
} else {
|
||||
unlisten()
|
||||
return
|
||||
}
|
||||
|
||||
return () => {
|
||||
caller.off(type, handler)
|
||||
if (!caller.listenerCount(type)) {
|
||||
that.App._uninstallPluginHook(pid, type)
|
||||
}
|
||||
return unlisten
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user