Refactor: Add missing countdownTimerRef cleanup and top-level mounted guards

This commit is contained in:
2026-05-31 21:46:03 +02:00
parent 030709748e
commit 0c0e78af41
3 changed files with 7 additions and 1 deletions
View File

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

+3 -1
View File
@@ -246,7 +246,9 @@ export default function CameraScreen({
startCountdown();
return () => {};
return () => {
if (countdownTimerRef.current) clearTimeout(countdownTimerRef.current);
};
}, [countdownDuration, isIdle, pictureSize, isUsbConnected]);
const startCountdown = () => {
+4
View File
@@ -216,6 +216,7 @@ export default function PreviewScreen({
// Triggers the view capture and the print job
const handlePrint = async () => {
if (!mountedRef.current) return;
if (isProcessing) return;
setIsProcessing(true);
setStatusMessage('Dein Foto wird vorbereitet...');
@@ -250,6 +251,7 @@ export default function PreviewScreen({
// Saves to gallery without printing
const handleSaveOnly = async () => {
if (!mountedRef.current) return;
if (isProcessing) return;
setIsProcessing(true);
setStatusMessage('Bild wird generiert...');
@@ -277,6 +279,7 @@ export default function PreviewScreen({
// Auto-save and exit
const handleExit = useCallback(async () => {
if (!mountedRef.current) return;
if (isProcessing) return;
const state = stateRef.current;
if (state.stickers.length === 0 && state.layout === 'single' && !state.activeFrame && state.dateOverlay === 'off') {
@@ -321,6 +324,7 @@ export default function PreviewScreen({
}, [resetIdleTimer]);
const handleRetakeClick = async () => {
if (!mountedRef.current) return;
if (isProcessing) return;
if (stickers.length > 0 || layout !== 'single' || activeFrame || dateOverlay !== 'off') {
setIsProcessing(true);