use .after FEN for move navigation

This commit is contained in:
Nathaniel Tampus
2023-03-19 21:18:16 +08:00
parent 4ee0cd2280
commit 802a03fa11

View File

@@ -430,7 +430,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
function navigateMove(index: number | null | "prev") { function navigateMove(index: number | null | "prev") {
const history = lobby.actualGame.history({ verbose: true }); 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 // last move
setNavIndex(null); setNavIndex(null);
setNavFen(null); setNavFen(null);
@@ -446,7 +446,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
chessboardRef.current?.clearPremoves(false); chessboardRef.current?.clearPremoves(false);
setNavIndex(index); setNavIndex(index);
setNavFen(history[index + 1].fen); setNavFen(history[index].after);
} }
function getNavMoveSquares() { function getNavMoveSquares() {