Fix calling option onChange listeners for legacy settings
This commit is contained in:
parent
72ec5e2023
commit
78c2f0d61a
2 changed files with 11 additions and 6 deletions
|
@ -73,8 +73,6 @@ function handleActivityToggle(e: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
||||||
const ignoredActivityIndex = settings.store.ignoredActivities.findIndex(act => act.id === activity.id);
|
const ignoredActivityIndex = settings.store.ignoredActivities.findIndex(act => act.id === activity.id);
|
||||||
if (ignoredActivityIndex === -1) settings.store.ignoredActivities.push(activity);
|
if (ignoredActivityIndex === -1) settings.store.ignoredActivities.push(activity);
|
||||||
else settings.store.ignoredActivities.splice(ignoredActivityIndex, 1);
|
else settings.store.ignoredActivities.splice(ignoredActivityIndex, 1);
|
||||||
|
|
||||||
recalculateActivities();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function recalculateActivities() {
|
function recalculateActivities() {
|
||||||
|
|
|
@ -141,14 +141,21 @@ for (const p of neededApiPlugins) {
|
||||||
|
|
||||||
for (const p of pluginsValues) {
|
for (const p of pluginsValues) {
|
||||||
if (p.settings) {
|
if (p.settings) {
|
||||||
p.settings.pluginName = p.name;
|
|
||||||
p.options ??= {};
|
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];
|
const checks = p.settings.checks?.[name];
|
||||||
p.options[name] = { ...def, ...checks };
|
p.options[name] = { ...def, ...checks };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (def.onChange != null) {
|
if (p.options) {
|
||||||
SettingsStore.addChangeListener(`plugins.${p.name}.${name}`, def.onChange);
|
for (const name in p.options) {
|
||||||
|
const opt = p.options[name];
|
||||||
|
if (opt.onChange != null) {
|
||||||
|
SettingsStore.addChangeListener(`plugins.${p.name}.${name}`, opt.onChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue