( initialFileHistorySnapshots: FileHistorySnapshot[] | undefined, fileHistoryState: FileHistoryState, onUpdateState: (newState: FileHistoryState) => void, )
| 7 | } from '../utils/fileHistory.js' |
| 8 | |
| 9 | export function useFileHistorySnapshotInit( |
| 10 | initialFileHistorySnapshots: FileHistorySnapshot[] | undefined, |
| 11 | fileHistoryState: FileHistoryState, |
| 12 | onUpdateState: (newState: FileHistoryState) => void, |
| 13 | ): void { |
| 14 | const initialized = useRef(false) |
| 15 | |
| 16 | useEffect(() => { |
| 17 | if (!fileHistoryEnabled() || initialized.current) { |
| 18 | return |
| 19 | } |
| 20 | initialized.current = true |
| 21 | if (initialFileHistorySnapshots) { |
| 22 | fileHistoryRestoreStateFromLog(initialFileHistorySnapshots, onUpdateState) |
| 23 | } |
| 24 | }, [fileHistoryState, initialFileHistorySnapshots, onUpdateState]) |
| 25 | } |
| 26 |
no test coverage detected