Chess on the ATmosphere checkmate.blue
chess
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix game result banner not showing for the winning player

The winning player's result banner (You win!) was not rendering after
delivering checkmate. The game.result getter relied on gameResult(chess)
which reads from a chess.js class instance mutated in place -- Svelte 5
runes don't track mutations on class instances, so the template never
re-evaluated. Fix by explicitly calling game.setResult() in writeMove()
which sets the storedResult $state variable, triggering reactivity.

+6 -4
+6 -4
src/routes/game/[did]/[rkey]/+page.svelte
··· 492 492 if (!auth.agent || !auth.did || !myRkey) return; 493 493 494 494 const pgn = makePgn(game.chess, game.whiteDid, game.blackDid); 495 + const result = gameResult(game.chess); 495 496 try { 496 497 await updateGame(auth.agent, myRkey, { 497 498 pgn, 498 - status: game.result ? 'completed' : 'active', 499 - result: game.result?.result, 500 - resultReason: game.result?.reason as any, 499 + status: result ? 'completed' : 'active', 500 + result: result?.result, 501 + resultReason: result?.reason as any, 501 502 drawOffered: false, 502 503 lastMoveAt: new Date().toISOString(), 503 504 }); 504 505 game.clearDrawOffers(); 505 506 lastPersistedPgn = pgn; 506 507 moveError = ''; 507 - if (game.result) { 508 + if (result) { 509 + game.setResult(result.result, result.reason); 508 510 game.setStatus('completed'); 509 511 sound.play('gameEnd'); 510 512 }