fix: admin/plugins: installing a plugin could result in a (temporary) duplicate in the installed list

Massimo Melina committed May 18, 2024 at 18:24 UTC 405c23778a3726ad993a1f59de81cfc15300a1b7
1 file changed +2 -1
src/plugins.ts
+2 -1
@@ -310,7 +310,7 @@ export async function rescan() {
310 function watchPlugin(id: string, path: string) {
311 const module = resolve(path)
312 let starting: PendingPromise | undefined
313 - enablePlugins.sub(() => { // we take care of enabled-state after it was loaded
313 + const unsub = enablePlugins.sub(() => { // we take care of enabled-state after it was loaded
314 if (!getPluginInfo(id)) return // not loaded yet
315 const enabled = isPluginEnabled(id)
316 if (enabled !== isPluginRunning(id))
@@ -328,6 +328,7 @@ function watchPlugin(id: string, path: string) {
328 events.emit(notRunning ? 'pluginUpdated' : 'pluginInstalled', p)
329 })
330 return () => {
331 + unsub()
332 unwatch()
333 return onUninstalled()
334 }