Download src/hooks/useFileHistorySnapshotInit.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 767 Bytes
-
https://huggingface.co/chenbhao/codev/resolve/main/src/hooks/useFileHistorySnapshotInit.ts
- Command line
-
hf download hf://chenbhao/codev/src/hooks/useFileHistorySnapshotInit.ts
-
curl -L -o useFileHistorySnapshotInit.ts https://huggingface.co/chenbhao/codev/resolve/main/src/hooks/useFileHistorySnapshotInit.ts
767 Bytes
| import { useEffect, useRef } from 'react' | |
| import { | |
| type FileHistorySnapshot, | |
| type FileHistoryState, | |
| fileHistoryEnabled, | |
| fileHistoryRestoreStateFromLog, | |
| } from '../utils/fileHistory.js' | |
| export function useFileHistorySnapshotInit( | |
| initialFileHistorySnapshots: FileHistorySnapshot[] | undefined, | |
| fileHistoryState: FileHistoryState, | |
| onUpdateState: (newState: FileHistoryState) => void, | |
| ): void { | |
| const initialized = useRef(false) | |
| useEffect(() => { | |
| if (!fileHistoryEnabled() || initialized.current) { | |
| return | |
| } | |
| initialized.current = true | |
| if (initialFileHistorySnapshots) { | |
| fileHistoryRestoreStateFromLog(initialFileHistorySnapshots, onUpdateState) | |
| } | |
| }, [fileHistoryState, initialFileHistorySnapshots, onUpdateState]) | |
| } | |