diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 13:43:23 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 13:43:23 +0100 |
| commit | b3ca050156f10aae285d2f7bfb873d9fa43bf3f4 (patch) | |
| tree | 02e8ce305f2a7b2038f778c52a6b9fe967d00237 /web/src/lib/ui/menus/NoteRowMenu.svelte | |
| parent | 93970f361b831f17d48ff2a345fc78488ac71fba (diff) | |
web: fix state_referenced_locally warnings
Read the session's stores through $derived instead of top-level consts,
so the session prop is read reactively and the existing store-rune
references keep their reactivity; make the card width/height constants
derived from the scale prop; seed the transient edit buffers
(note/figure note, rename fields) from props once on mount with an
explicit svelte-ignore, since the menu is remounted when opened and a
later prop change must not clobber an in-progress edit.
Also fixes a latent bug in LootEnhancementCounter where the buttons
tested !player (the store object, always truthy) instead of !$player,
so the enhancement buttons were never disabled for spectators.
Diffstat (limited to 'web/src/lib/ui/menus/NoteRowMenu.svelte')
| -rw-r--r-- | web/src/lib/ui/menus/NoteRowMenu.svelte | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/web/src/lib/ui/menus/NoteRowMenu.svelte b/web/src/lib/ui/menus/NoteRowMenu.svelte index 78f25f9..d7be25a 100644 --- a/web/src/lib/ui/menus/NoteRowMenu.svelte +++ b/web/src/lib/ui/menus/NoteRowMenu.svelte @@ -50,16 +50,23 @@ open?: boolean; } = $props(); - const player = session.player; - const gameState = session.state; + const player = $derived(session.player); + const gameState = $derived(session.state); const isEdit = $derived(note != null); const canAct = $derived(!!$player && $gameState != null); + // The edit buffers are seeded from the props once on mount (the menu is + // remounted when opened); later prop changes must not clobber the edit. + // svelte-ignore state_referenced_locally let text = $state(note?.text ?? ''); + // svelte-ignore state_referenced_locally let color = $state(note?.color ?? 0xff4e5d6c); + // svelte-ignore state_referenced_locally let linkedId = $state(note?.linkedId ?? presetLinkId); + // svelte-ignore state_referenced_locally let standeeNr = $state(note?.standeeNr ?? presetStandeeNr); + // svelte-ignore state_referenced_locally let lastCommitted = $state(text); function colorCss(c: number): string { |
