diff options
author | metamuffin <metamuffin@disroot.org> | 2024-04-02 10:53:45 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-04-02 10:53:45 +0200 |
commit | 2accfbcda2aac18195ca9ec2017c91ea243bbf94 (patch) | |
tree | 955a102e7f5e84bd21c87f6d36a883e5f429cec5 /client-web/source/preferences | |
parent | 1cbb982e0910f9ed9c425e5a87967b2295d1ee32 (diff) | |
download | keks-meet-2accfbcda2aac18195ca9ec2017c91ea243bbf94.tar keks-meet-2accfbcda2aac18195ca9ec2017c91ea243bbf94.tar.bz2 keks-meet-2accfbcda2aac18195ca9ec2017c91ea243bbf94.tar.zst |
fix weird behaviour in disabled settings
Diffstat (limited to 'client-web/source/preferences')
-rw-r--r-- | client-web/source/preferences/decl.ts | 1 | ||||
-rw-r--r-- | client-web/source/preferences/ui.ts | 20 |
2 files changed, 14 insertions, 7 deletions
diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts index a8c33a6..269e247 100644 --- a/client-web/source/preferences/decl.ts +++ b/client-web/source/preferences/decl.ts @@ -33,6 +33,7 @@ export const PREF_DECLS = { video_fps: { type: number }, video_resolution: { type: number }, camera_facing_mode: { type: optional(string), possible_values: ["environment", "user"] }, + screencast_audio: { type: bool, default: false }, auto_gain_control: { type: bool }, echo_cancellation: { type: bool, allow_url: true }, audio_activity_threshold: { type: number, optional: true, default: 0.003 }, diff --git a/client-web/source/preferences/ui.ts b/client-web/source/preferences/ui.ts index 1be4458..252cba8 100644 --- a/client-web/source/preferences/ui.ts +++ b/client-web/source/preferences/ui.ts @@ -15,19 +15,22 @@ export function ui_preferences(): HTMLElement { const key = key_ as keyof typeof PREF_DECLS const id = `pref-${key}` let prim_control: HTMLInputElement | HTMLSelectElement | undefined; - if (decl.possible_values) { + if (decl.possible_values && typeof decl.type == "string") { const sel = document.createElement("select") sel.id = id - for (const v of decl.possible_values) { + for (const v of decl.possible_values as string[]) { const opt = document.createElement("option") - opt.value = opt.textContent = JSON.stringify(v ?? null) + opt.value = opt.textContent = v ?? "" sel.append(opt) } sel.onchange = () => { - change_pref(key, JSON.parse(sel.value) ?? undefined) + if (!sel.value.length) return + change_pref(key, sel.value ?? undefined) } - on_pref_changed(key, () => sel.value = JSON.stringify(PREFS[key] ?? null)) - sel.value = JSON.stringify(PREFS[key]) + on_pref_changed(key, () => { + sel.value = PREFS[key] as string ?? "" + }) + sel.value = PREFS[key] as string prim_control = sel } else if (typeof decl.type == "boolean") { const checkbox = document.createElement("input") @@ -57,7 +60,9 @@ export function ui_preferences(): HTMLElement { textbox.onchange = () => { change_pref(key, parseFloat(textbox.value)) } - on_pref_changed(key, () => textbox.value = PREFS[key] as string) + on_pref_changed(key, () => { + textbox.value = PREFS[key] as string + }) prim_control = textbox } @@ -69,6 +74,7 @@ export function ui_preferences(): HTMLElement { use_opt.checked = PREFS[key] !== undefined if (prim_control) prim_control.disabled = !use_opt.checked use_opt.onchange = () => { + if (prim_control) prim_control.disabled = !use_opt.checked if (use_opt.checked) { if (prim_control?.onchange) prim_control.onchange(new Event("change")) } else change_pref(key, undefined) } |