mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 09:56:57 +00:00
trigger reducer pased on if the diagram is in the position or not
This commit is contained in:
@@ -87,8 +87,17 @@ export const useChessGame = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleToggleDiagram = ({ ply, fen }: { ply: number; fen: string }) => {
|
const handleToggleDiagram = () => {
|
||||||
console.log("Toggle diagram", ply, fen);
|
if (!gameState.pgn) return;
|
||||||
|
const { ply, fen } = currentPosition;
|
||||||
|
if (ply === 0) return;
|
||||||
|
const exists = gameState.diagrams.some((d) => d.ply === ply);
|
||||||
|
|
||||||
|
gameDispatch(
|
||||||
|
exists
|
||||||
|
? { type: "DELETE_DIAGRAM", payload: { ply } }
|
||||||
|
: { type: "ADD_DIAGRAM", payload: { ply, fen } },
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user