Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions frontend/src/ts/elements/settings/settings-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,22 @@ export default class SettingsGroup<K extends ConfigKey, T = ConfigType[K]> {
const newValue = valueOverride ?? (Config[this.configName] as T);

if (this.mode === "select") {
const select = this.elements?.[0] as HTMLSelectElement | null | undefined;
const select = this.elements?.[0] as
| ElementWithUtils<HTMLSelectElement>
| undefined;
if (!select) {
return;
}

//@ts-expect-error this is fine, slimselect adds slim to the element
const ss = select.slim as SlimSelect | undefined;
const ss = select.native.slim as SlimSelect | undefined;
if (ss !== undefined) {
const currentSelected = ss.getSelected()[0] ?? null;
if (newValue !== currentSelected) {
ss.setSelected(newValue as string);
}
} else {
if (select.value !== newValue) select.value = newValue as string;
if (select.getValue() !== newValue) select.setValue(newValue as string);
}
} else if (this.mode === "button") {
for (const button of this.elements) {
Expand All @@ -236,18 +238,20 @@ export default class SettingsGroup<K extends ConfigKey, T = ConfigType[K]> {
}
}
} else if (this.mode === "range") {
const range = this.elements?.[0] as HTMLInputElement | null | undefined;
const range = this.elements?.[0] as
| ElementWithUtils<HTMLInputElement>
| undefined;

const rangeValue = document.querySelector(
const rangeValue = qs(
`.pageSettings .section[data-config-name='${this.configName}'] .value`,
);

if (range === undefined || range === null || rangeValue === null) {
return;
}

range.value = newValue as unknown as string;
rangeValue.textContent = `${(newValue as number).toFixed(1)}`;
range.setValue(newValue as unknown as string);
rangeValue.setText(`${(newValue as number).toFixed(1)}`);
}
if (this.updateCallback) this.updateCallback();
}
Expand Down
Loading