Skip to content

Commit 0cff434

Browse files
committed
fix: incorporate flip state in useSolutionContents for dynamic coordinate mapping
1 parent eacb5ab commit 0cff434

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/client/run.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ export const useFlip = () => useAtom(flipAtom);
2525

2626
export function useSolutionContents() {
2727
const [file] = useSolutionFile();
28+
const [flip] = useFlip();
2829
return useQuery({
29-
queryKey: ["solution", id(file)],
30+
queryKey: ["solution", id(file), flip],
3031
queryFn: async () => {
3132
if (!file) return;
3233
const text = await file.text();
@@ -39,7 +40,7 @@ export function useSolutionContents() {
3940
const pairs = p.split("->");
4041
return pairs.filter(identity).map((p) => {
4142
const [x, y] = trim(p, "()").split(",");
42-
return { x: +x, y: +y };
43+
return flip ? { x: +x, y: +y } : { x: +y, y: +x };
4344
});
4445
}),
4546
};

0 commit comments

Comments
 (0)