This commit is contained in:
Louis Mazin 2026-09-15 19:37:59 +02:00
parent b54bbd018a
commit dee38ad8dc

View File

@ -120,8 +120,15 @@ const TimeClockPage = () => {
}; };
const stopScanner = () => { const stopScanner = () => {
qrControlsRef.current?.stop(); const controls = qrControlsRef.current;
qrControlsRef.current = null; qrControlsRef.current = null;
try {
controls?.stop();
} catch (stopError) {
console.warn('Arrêt du lecteur QR déjà effectué.', stopError);
}
if (scanFrameRef.current) { if (scanFrameRef.current) {
cancelAnimationFrame(scanFrameRef.current); cancelAnimationFrame(scanFrameRef.current);
scanFrameRef.current = null; scanFrameRef.current = null;
@ -156,7 +163,11 @@ const TimeClockPage = () => {
); );
if (cancelled) { if (cancelled) {
controls.stop(); try {
controls.stop();
} catch (stopError) {
console.warn('Arrêt du lecteur QR déjà effectué.', stopError);
}
} else { } else {
qrControlsRef.current = controls; qrControlsRef.current = controls;
} }
@ -173,7 +184,11 @@ const TimeClockPage = () => {
return () => { return () => {
cancelled = true; cancelled = true;
reader.reset(); try {
reader.reset();
} catch (resetError) {
console.warn('Réinitialisation du lecteur QR ignorée.', resetError);
}
}; };
}, [isScanning]); }, [isScanning]);