Skip to content

Commit 812cd5f

Browse files
committed
refactor: resolve incorrect event category handling in hints.
1 parent 27f72f1 commit 812cd5f

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/components/timer/HintPanel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export default function HintPanel() {
1414
const { lang } = useSettingsModalStore();
1515
const componentRef = useRef<HTMLDivElement | null>(null);
1616
useClickOutside(componentRef, () => setDisplayHint(false));
17-
const solutions = genSolution("3x3", scramble, "yellow");
17+
18+
if (!selectedCube) return null;
19+
const solutions = genSolution(selectedCube.category, scramble, "yellow");
20+
1821
return (
1922
<>
2023
<AnimatePresence>

src/lib/timer/genSolution.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ export default function genSolution(
2323
eoline: [],
2424
};
2525

26-
if (event === "3x3" && scramble) {
27-
if (layer === "yellow") {
28-
solution.cross.push(cubeSolver.solve(`${scramble}`, "cross"));
29-
solution.cross.push(cubeSolver.solve(`y ${scramble}`, "cross"));
30-
solution.cross.push(cubeSolver.solve(`y y ${scramble}`, "cross"));
31-
solution.cross.push(cubeSolver.solve(`y' ${scramble}`, "cross"));
32-
solution.xcross.push(cubeSolver.solve(`${scramble}`, "xcross"));
33-
solution.xcross.push(cubeSolver.solve(`y ${scramble}`, "xcross"));
34-
solution.xcross.push(cubeSolver.solve(`y y ${scramble}`, "xcross"));
35-
solution.xcross.push(cubeSolver.solve(`y' ${scramble}`, "xcross"));
36-
}
26+
if (event !== "3x3") return solution;
27+
28+
if (layer === "yellow") {
29+
solution.cross.push(cubeSolver.solve(`${scramble}`, "cross"));
30+
solution.cross.push(cubeSolver.solve(`y ${scramble}`, "cross"));
31+
solution.cross.push(cubeSolver.solve(`y y ${scramble}`, "cross"));
32+
solution.cross.push(cubeSolver.solve(`y' ${scramble}`, "cross"));
33+
solution.xcross.push(cubeSolver.solve(`${scramble}`, "xcross"));
34+
solution.xcross.push(cubeSolver.solve(`y ${scramble}`, "xcross"));
35+
solution.xcross.push(cubeSolver.solve(`y y ${scramble}`, "xcross"));
36+
solution.xcross.push(cubeSolver.solve(`y' ${scramble}`, "xcross"));
3737
}
38+
3839
return solution;
3940
}

0 commit comments

Comments
 (0)