Skip to content

Commit

Permalink
Revert "Reset selected cube after delete"
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlundberg authored Oct 29, 2023
1 parent deae6fd commit 5ec82bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/hooks/useModalCube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function useModalCube() {
setCubeName,
} = useCubesModalStore();
const { lang } = useSettingsModalStore();
const { setCubes, setSelectedCube, setNewScramble, selectedCube } = useTimerStore();
const { setCubes } = useTimerStore();
const [error, setError] = useState<boolean>(false);

const handleClickRadio = (category: Categories) => {
Expand Down Expand Up @@ -73,12 +73,6 @@ export default function useModalCube() {
if (!editingCube) return;
const updatedCubeDB = cubeDB.filter((cube) => cube.id !== editingCube.id);
window.localStorage.setItem("cubes", JSON.stringify(updatedCubeDB));

if (selectedCube && selectedCube.id === editingCube.id) {
setSelectedCube(null);
setNewScramble(null);
}

setCubes(updatedCubeDB);
setModalOpen(false);
setEditingCube(null);
Expand Down
10 changes: 3 additions & 7 deletions src/store/timerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,17 @@ export const useTimerStore = create<TimerStore>((set) => ({
lastSolve: null,
solvingTime: 0,
isSolving: false,
setNewScramble: (cube: Cube | null) => {
setNewScramble: (cube: Cube) => {
set((state) => ({
...state,
scramble: cube ? genScramble(cube.category) : null,
scramble: genScramble(cube.category),
}));
},
setCubes: (cubes: Cube[]) => {
set((state) => ({ ...state, cubes }));
},
setSelectedCube: (cube: Cube | null) => {
setSelectedCube: (cube: Cube) => {
set((state: any) => {
if (!cube) {
return { ...state, event: null, selectedCube: null };
}

const selectedEvent = cubeCollection.find(
(item) => item.name === cube.category
);
Expand Down

0 comments on commit 5ec82bc

Please sign in to comment.