Refactor: Add missing countdownTimerRef cleanup and top-level mounted guards
This commit is contained in:
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
@@ -246,7 +246,9 @@ export default function CameraScreen({
|
|||||||
|
|
||||||
startCountdown();
|
startCountdown();
|
||||||
|
|
||||||
return () => {};
|
return () => {
|
||||||
|
if (countdownTimerRef.current) clearTimeout(countdownTimerRef.current);
|
||||||
|
};
|
||||||
}, [countdownDuration, isIdle, pictureSize, isUsbConnected]);
|
}, [countdownDuration, isIdle, pictureSize, isUsbConnected]);
|
||||||
|
|
||||||
const startCountdown = () => {
|
const startCountdown = () => {
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ export default function PreviewScreen({
|
|||||||
|
|
||||||
// Triggers the view capture and the print job
|
// Triggers the view capture and the print job
|
||||||
const handlePrint = async () => {
|
const handlePrint = async () => {
|
||||||
|
if (!mountedRef.current) return;
|
||||||
if (isProcessing) return;
|
if (isProcessing) return;
|
||||||
setIsProcessing(true);
|
setIsProcessing(true);
|
||||||
setStatusMessage('Dein Foto wird vorbereitet...');
|
setStatusMessage('Dein Foto wird vorbereitet...');
|
||||||
@@ -250,6 +251,7 @@ export default function PreviewScreen({
|
|||||||
|
|
||||||
// Saves to gallery without printing
|
// Saves to gallery without printing
|
||||||
const handleSaveOnly = async () => {
|
const handleSaveOnly = async () => {
|
||||||
|
if (!mountedRef.current) return;
|
||||||
if (isProcessing) return;
|
if (isProcessing) return;
|
||||||
setIsProcessing(true);
|
setIsProcessing(true);
|
||||||
setStatusMessage('Bild wird generiert...');
|
setStatusMessage('Bild wird generiert...');
|
||||||
@@ -277,6 +279,7 @@ export default function PreviewScreen({
|
|||||||
|
|
||||||
// Auto-save and exit
|
// Auto-save and exit
|
||||||
const handleExit = useCallback(async () => {
|
const handleExit = useCallback(async () => {
|
||||||
|
if (!mountedRef.current) return;
|
||||||
if (isProcessing) return;
|
if (isProcessing) return;
|
||||||
const state = stateRef.current;
|
const state = stateRef.current;
|
||||||
if (state.stickers.length === 0 && state.layout === 'single' && !state.activeFrame && state.dateOverlay === 'off') {
|
if (state.stickers.length === 0 && state.layout === 'single' && !state.activeFrame && state.dateOverlay === 'off') {
|
||||||
@@ -321,6 +324,7 @@ export default function PreviewScreen({
|
|||||||
}, [resetIdleTimer]);
|
}, [resetIdleTimer]);
|
||||||
|
|
||||||
const handleRetakeClick = async () => {
|
const handleRetakeClick = async () => {
|
||||||
|
if (!mountedRef.current) return;
|
||||||
if (isProcessing) return;
|
if (isProcessing) return;
|
||||||
if (stickers.length > 0 || layout !== 'single' || activeFrame || dateOverlay !== 'off') {
|
if (stickers.length > 0 || layout !== 'single' || activeFrame || dateOverlay !== 'off') {
|
||||||
setIsProcessing(true);
|
setIsProcessing(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user