From 78c2f0d61a475d6a714918a54fc4f4c30720729f Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:43:33 -0300 Subject: [PATCH] Fix calling option onChange listeners for legacy settings --- src/plugins/ignoreActivities/index.tsx | 2 -- src/plugins/index.ts | 15 +++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 08e146ab9..ee09ef432 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -73,8 +73,6 @@ function handleActivityToggle(e: React.MouseEvent const ignoredActivityIndex = settings.store.ignoredActivities.findIndex(act => act.id === activity.id); if (ignoredActivityIndex === -1) settings.store.ignoredActivities.push(activity); else settings.store.ignoredActivities.splice(ignoredActivityIndex, 1); - - recalculateActivities(); } function recalculateActivities() { diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 545169b1f..50523e98f 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -141,14 +141,21 @@ for (const p of neededApiPlugins) { for (const p of pluginsValues) { if (p.settings) { - p.settings.pluginName = p.name; p.options ??= {}; - for (const [name, def] of Object.entries(p.settings.def)) { + + p.settings.pluginName = p.name; + for (const name in p.settings.def) { + const def = p.settings.def[name]; const checks = p.settings.checks?.[name]; p.options[name] = { ...def, ...checks }; + } + } - if (def.onChange != null) { - SettingsStore.addChangeListener(`plugins.${p.name}.${name}`, def.onChange); + if (p.options) { + for (const name in p.options) { + const opt = p.options[name]; + if (opt.onChange != null) { + SettingsStore.addChangeListener(`plugins.${p.name}.${name}`, opt.onChange); } } }