The hall's table selectors read from and write to the preferences, so the panel and the hall agree

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
Eric Wagoner
2026-09-23 18:58:18 -04:00
co-authored by Claude Fable 5.1
parent 74df9a253a
commit c0254e3fe9
+3 -6
View File
@@ -16,13 +16,10 @@
let name = $state(playerName()); let name = $state(playerName());
let code = $state(''); let code = $state('');
/** The host's choices for the next table, from the game's declared options. */ /** The host's choices for the next table, from the game's declared options. */
// A new table starts from the preferences' table defaults, which the hall's own selectors also set. // A new table starts from the preferences' table defaults; the hall's selectors set the same keys.
let options = $state<Record<string, string>>( const options = $derived<Record<string, string>>(
Object.fromEntries((game.options ?? []).map((o) => [o.key, o.choices.some((c) => c.value === prefs[`table.${o.key}`]) ? String(prefs[`table.${o.key}`]) : o.default])) Object.fromEntries((game.options ?? []).map((o) => [o.key, o.choices.some((c) => c.value === prefs[`table.${o.key}`]) ? String(prefs[`table.${o.key}`]) : o.default]))
); );
$effect(() => {
for (const o of game.options ?? []) if (prefs[`table.${o.key}`] !== options[o.key]) setPref(`table.${o.key}`, options[o.key]);
});
let prefsOpen = $state(false); let prefsOpen = $state(false);
let busy = $state(false); let busy = $state(false);
let error = $state(''); let error = $state('');
@@ -182,7 +179,7 @@
<div class="option-block"> <div class="option-block">
<label class="option"> <label class="option">
<span>{o.label}</span> <span>{o.label}</span>
<select bind:value={options[o.key]}> <select value={options[o.key]} onchange={(e) => setPref(`table.${o.key}`, e.currentTarget.value)}>
{#each o.choices as c (c.value)}<option value={c.value}>{c.label}</option>{/each} {#each o.choices as c (c.value)}<option value={c.value}>{c.label}</option>{/each}
</select> </select>
</label> </label>