fix(chess): optimistic moves and forfeit UI feedback
Some checks failed
Deploy to Production / test (push) Failing after 31s
Some checks failed
Deploy to Production / test (push) Failing after 31s
- Add localFen/localFenRef in ChessBoard for optimistic piece placement, preventing snap-back while awaiting server confirmation - Sync localFen from server state on each chess.fen update - Guard GAME_STATE handler in useGameRoom from overwriting a finished roomStatus, fixing the race where GAME_ENDED (pub/sub) arrives before GAME_STATE (direct ws.send) - Reset confirmForfeit immediately on forfeit dispatch for instant UI feedback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,7 +58,11 @@ export function useGameRoom(roomId: string, userId: string, role?: string, prefe
|
||||
break;
|
||||
|
||||
case "GAME_STATE":
|
||||
setState(prev => ({ ...prev, gameState: msg.state, roomStatus: "playing" }));
|
||||
setState(prev => ({
|
||||
...prev,
|
||||
gameState: msg.state,
|
||||
roomStatus: prev.roomStatus === "finished" ? "finished" : "playing",
|
||||
}));
|
||||
break;
|
||||
|
||||
case "GAME_STARTED":
|
||||
|
||||
Reference in New Issue
Block a user