fix(client): guard phantom-store mutations against unset game and no-op move

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
claude (blind_chess)
2026-05-18 20:27:25 -04:00
parent 0583984723
commit bd98315fe3
@@ -38,11 +38,13 @@ function makeStore() {
}
function place(sq: Square, type: PieceType) {
if (!gameId) return;
state.phantoms = { ...state.phantoms, [sq]: { color: oppColor, type } };
persist();
}
function move(from: Square, to: Square) {
if (!gameId || from === to) return;
const p = state.phantoms[from];
if (!p) return;
const next = { ...state.phantoms };
@@ -53,6 +55,7 @@ function makeStore() {
}
function remove(sq: Square) {
if (!gameId) return;
const next = { ...state.phantoms };
delete next[sq];
state.phantoms = next;