From 802a03fa1144cf7fc60ffbda3445b2a45008d8ef Mon Sep 17 00:00:00 2001 From: Nathaniel Tampus Date: Sun, 19 Mar 2023 21:18:16 +0800 Subject: [PATCH] use .after FEN for move navigation --- client/src/components/game/GamePage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/game/GamePage.tsx b/client/src/components/game/GamePage.tsx index 846ac61..31b41e0 100644 --- a/client/src/components/game/GamePage.tsx +++ b/client/src/components/game/GamePage.tsx @@ -430,7 +430,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { function navigateMove(index: number | null | "prev") { const history = lobby.actualGame.history({ verbose: true }); - if (index === null || index >= history.length - 1 || !history.length) { + if (index === null || (index !== "prev" && index >= history.length - 1) || !history.length) { // last move setNavIndex(null); setNavFen(null); @@ -446,7 +446,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { chessboardRef.current?.clearPremoves(false); setNavIndex(index); - setNavFen(history[index + 1].fen); + setNavFen(history[index].after); } function getNavMoveSquares() {