source dump of claude code
at main 25 lines 767 B view raw
1import { useEffect, useRef } from 'react' 2import { 3 type FileHistorySnapshot, 4 type FileHistoryState, 5 fileHistoryEnabled, 6 fileHistoryRestoreStateFromLog, 7} from '../utils/fileHistory.js' 8 9export 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}