@samitouri / QOSami-HFS / commits / fd821745

fix: deleting a stopped plugin displayed console message "switching plugin off"

Massimo Melina committed Jun 30, 2023 at 15:05 UTC fd82174542659ff973639a524be33e0925c57019
1 file changed +6 -4
src/plugins.ts
+6 -4
@@ -48,12 +48,14 @@ export function isPluginEnabled(id: string) {
48 export function enablePlugin(id: string, state=true) {
49 if (state && !getPluginInfo(id))
50 throw Error('miss')
51 - console.log("switching plugin", id, state ? "on" : "off")
52 - enablePlugins.set( arr =>
53 - arr.includes(id) === state ? arr
51 + enablePlugins.set(arr => {
52 + if (arr.includes(id) === state)
53 + return arr
54 + console.log("switching plugin", id, state ? "on" : "off")
55 + return arr.includes(id) === state ? arr
56 : state ? [...arr, id]
57 : arr.filter((x: string) => x !== id)
56 - )
58 + })
59 }
60
61 export async function stopPlugin(id: string) {