Spaces:
Running
Running
Download algospaced-ui/src/hooks/useWindowManager.ts from iamfebin/algospaced-dsa: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/algospaced-ui/src/hooks/useWindowManager.ts
- Command line
-
hf download hf://spaces/iamfebin/algospaced-dsa/algospaced-ui/src/hooks/useWindowManager.ts
-
curl -L -o useWindowManager.ts https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/algospaced-ui/src/hooks/useWindowManager.ts
2.47 kB
| import { useCallback, useMemo } from 'react'; | |
| import { useOSStore } from '../stores/useOSStore'; | |
| import type { WindowId, WindowsMap, WindowState } from '../types/windowTypes'; | |
| import type { ProblemItem } from '../types/reviewTypes'; | |
| export function useWindowManager(onStartMenuClose?: () => void) { | |
| const windows = useOSStore(s => s.windows); | |
| const activeWindow = useOSStore(s => s.activeWindow); | |
| const overrideProblemId = useOSStore(s => s.overrideProblemId); | |
| const editingProblem = useOSStore(s => s.editingProblem); | |
| const refreshExplorerTrigger = useOSStore(s => s.refreshExplorerTrigger); | |
| const openWindow = useCallback((id: string) => { | |
| useOSStore.getState().openWindow(id); | |
| if (onStartMenuClose) { | |
| onStartMenuClose(); | |
| } | |
| }, [onStartMenuClose]); | |
| const closeWindow = useCallback((id: string) => { | |
| useOSStore.getState().closeWindow(id); | |
| }, []); | |
| const minimizeWindow = useCallback((id: string) => { | |
| useOSStore.getState().minimizeWindow(id); | |
| }, []); | |
| const toggleWindowMinimize = useCallback((id: string) => { | |
| useOSStore.getState().toggleWindowMinimize(id); | |
| }, []); | |
| const setActiveWindow = useCallback((id: string) => { | |
| useOSStore.getState().setActiveWindow(id); | |
| }, []); | |
| const setOverrideProblemId = useCallback((id: string | null) => { | |
| useOSStore.getState().setOverrideProblemId(id); | |
| }, []); | |
| const setEditingProblem = useCallback((problem: ProblemItem | null) => { | |
| useOSStore.getState().setEditingProblem(problem); | |
| }, []); | |
| const openEditProblem = useCallback((problem: ProblemItem) => { | |
| useOSStore.getState().openEditProblem(problem); | |
| }, []); | |
| const handleSelectProblemForReview = useCallback((problemId: string) => { | |
| useOSStore.getState().handleSelectProblemForReview(problemId); | |
| }, []); | |
| const triggerRefreshExplorer = useCallback(() => { | |
| useOSStore.getState().triggerRefreshExplorer(); | |
| }, []); | |
| const isAnyWindowOpen = useMemo(() => { | |
| return Object.values(windows).some(w => w.isOpen && !w.isMinimized); | |
| }, [windows]); | |
| return { | |
| windows, | |
| activeWindow, | |
| setActiveWindow, | |
| overrideProblemId, | |
| setOverrideProblemId, | |
| editingProblem, | |
| setEditingProblem, | |
| openEditProblem, | |
| refreshExplorerTrigger, | |
| openWindow, | |
| closeWindow, | |
| minimizeWindow, | |
| toggleWindowMinimize, | |
| handleSelectProblemForReview, | |
| triggerRefreshExplorer, | |
| isAnyWindowOpen | |
| }; | |
| } | |
| export type { WindowId, WindowsMap, WindowState }; | |