fix(client): key phantom-load effect on gameId, gate the drag ghost

Re-key the phantom-load effect on `loadedFor` (tracks gameId) so it
reloads if the same <Game> instance is reused for a different game
without a remount. Also gate the drag-ghost block behind
`phantomLayerEnabled` for consistency with all other phantom UI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
claude (blind_chess)
2026-05-18 20:50:13 -04:00
parent 313837eb21
commit 82a69d8812
+9 -6
View File
@@ -110,14 +110,17 @@
return a && phantomDrag.state.moved ? a.type : null; return a && phantomDrag.state.moved ? a.type : null;
}); });
// Load the phantom layer once `you` is known (blind games only). // Load the phantom layer when `you` is known (blind games only). Keyed on
let phantomsLoaded = $state(false); // gameId — like the connection effect — so it reloads if this <Game>
// instance is reused for a different game without a remount.
let loadedFor: string | null = $state(null);
$effect(() => { $effect(() => {
if (phantomsLoaded) return; const id = gameId;
const you = game.state.you; const you = game.state.you;
if (loadedFor === id) return;
if (you && game.state.mode === 'blind') { if (you && game.state.mode === 'blind') {
untrack(() => phantoms.loadForGame(gameId, you)); untrack(() => phantoms.loadForGame(id, you));
phantomsLoaded = true; loadedFor = id;
} }
}); });
@@ -210,7 +213,7 @@
{/if} {/if}
</div> </div>
{#if dragGhost} {#if phantomLayerEnabled && dragGhost}
<div <div
class="drag-ghost piece-{oppColor}" class="drag-ghost piece-{oppColor}"
style="left: {phantomDrag.state.x}px; top: {phantomDrag.state.y}px;" style="left: {phantomDrag.state.x}px; top: {phantomDrag.state.y}px;"