diff --git a/src/hooks/useModalCube.ts b/src/hooks/useModalCube.ts index 4f89393d..c6422c95 100644 --- a/src/hooks/useModalCube.ts +++ b/src/hooks/useModalCube.ts @@ -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(false); const handleClickRadio = (category: Categories) => { @@ -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); diff --git a/src/store/timerStore.ts b/src/store/timerStore.ts index 101938bc..4335fc16 100644 --- a/src/store/timerStore.ts +++ b/src/store/timerStore.ts @@ -28,21 +28,17 @@ export const useTimerStore = create((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 );