Skip to content

Commit

Permalink
fix custom fen in new game (closes #333)
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Dec 5, 2024
1 parent 182f665 commit 9a34f0b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/components/boards/BoardGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ import {
} from "@/state/atoms";
import { type TimeControlField, getMainLine } from "@/utils/chess";
import { positionFromFen } from "@/utils/chessops";
import type { EngineSettings, LocalEngine } from "@/utils/engines";
import {
type GameHeaders,
getNodeAtPath,
treeIteratorMainLine,
} from "@/utils/treeReducer";
import type { LocalEngine } from "@/utils/engines";
import { type GameHeaders, treeIteratorMainLine } from "@/utils/treeReducer";
import {
ActionIcon,
Box,
Button,
Center,
Checkbox,
Divider,
Group,
Expand Down Expand Up @@ -317,7 +312,6 @@ function BoardGame() {

const store = useContext(TreeStateContext)!;
const root = useStore(store, (s) => s.root);
const position = useStore(store, (s) => s.position);
const headers = useStore(store, (s) => s.headers);
const setFen = useStore(store, (s) => s.setFen);
const setHeaders = useStore(store, (s) => s.setHeaders);
Expand All @@ -336,7 +330,6 @@ function BoardGame() {
);
}
const mainLine = Array.from(treeIteratorMainLine(root));
const currentNode = getNodeAtPath(root, position);
const lastNode = mainLine[mainLine.length - 1].node;
const moves = useMemo(
() => getMainLine(root, headers.variant === "Chess960"),
Expand Down Expand Up @@ -535,6 +528,7 @@ function BoardGame() {
setHeaders({
...headers,
...newHeaders,
fen: root.fen,
});

setTabs((prev) =>
Expand Down

0 comments on commit 9a34f0b

Please sign in to comment.