optimized plugins' config

Massimo Melina committed Apr 25, 2022 at 22:33 UTC cbad8a58e9e0d865cec4b1d5ac32aadd7a9f75ff
1 file changed +7 -2
server/src/adminApis.ts
+7 -2
@@ -178,8 +178,13 @@ export const adminApis: ApiHandlers = {
178 setConfig({ [cfgK]: disable ? [...a, id] : a.filter((x: string) => x !== id) })
179 }
180 if (config) {
181 - const o = { ...getConfig(CFG_PLUGINS_CONFIG), [id]: config }
182 - setConfig({ [CFG_PLUGINS_CONFIG]: o })
181 + config = _.pickBy(config, v => v !== null)
182 + const o = { ...getConfig(CFG_PLUGINS_CONFIG) }
183 + if (_.isEmpty(config))
184 + delete o[id]
185 + else
186 + o[id] = config
187 + setConfig({ [CFG_PLUGINS_CONFIG]: _.isEmpty(o) ? undefined : o })
188 }
189 return {}
190 },