Fix final 4 resilience edge cases
This commit is contained in:
@@ -289,8 +289,8 @@ export default function PreviewScreen({
|
||||
}
|
||||
};
|
||||
|
||||
// Auto-save and exit
|
||||
const handleExit = useCallback(async () => {
|
||||
const handleExitRef = useRef<() => void>();
|
||||
handleExitRef.current = async () => {
|
||||
if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
|
||||
if (!mountedRef.current) return;
|
||||
if (isProcessing) return;
|
||||
@@ -319,15 +319,20 @@ export default function PreviewScreen({
|
||||
setIsProcessing(false);
|
||||
state.onReset();
|
||||
}
|
||||
}, []); // Stable reference
|
||||
};
|
||||
|
||||
// Auto-save and exit
|
||||
const handleExit = useCallback(async () => {
|
||||
if (handleExitRef.current) handleExitRef.current();
|
||||
}, []);
|
||||
|
||||
// Idle timer logic
|
||||
const resetIdleTimer = useCallback(() => {
|
||||
if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
|
||||
idleTimerRef.current = setTimeout(() => {
|
||||
handleExit();
|
||||
if (handleExitRef.current) handleExitRef.current();
|
||||
}, 60000);
|
||||
}, [handleExit]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
resetIdleTimer();
|
||||
|
||||
Reference in New Issue
Block a user