Skip to content

Commit

Permalink
Merge pull request #38320 from agent3bood/issue/36520-Android---Scan-…
Browse files Browse the repository at this point in the history
…--Second-tap-on-capture-button-causes-error-to-show-up

Issue/36520 android  scan second tap on capture button causes error to show up
  • Loading branch information
techievivek authored Apr 3, 2024
2 parents 6463de6 + 8f820e1 commit 879378f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pages/iou/request/step/IOURequestStepScan/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function IOURequestStepScan({
const camera = useRef(null);
const [flash, setFlash] = useState(false);
const [cameraPermissionStatus, setCameraPermissionStatus] = useState(undefined);
const [didCapturePhoto, setDidCapturePhoto] = useState(false);

const {translate} = useLocalize();

Expand Down Expand Up @@ -124,6 +125,7 @@ function IOURequestStepScan({

useFocusEffect(
useCallback(() => {
setDidCapturePhoto(false);
const refreshCameraPermissionStatus = () => {
CameraPermission.getCameraPermissionStatus()
.then(setCameraPermissionStatus)
Expand Down Expand Up @@ -236,6 +238,10 @@ function IOURequestStepScan({
return;
}

if (didCapturePhoto) {
return;
}

return camera.current
.takePhoto({
flash: flash && hasFlash ? 'on' : 'off',
Expand All @@ -252,13 +258,15 @@ function IOURequestStepScan({
return;
}

setDidCapturePhoto(true);
navigateToConfirmationStep();
})
.catch((error) => {
setDidCapturePhoto(false);
showCameraAlert();
Log.warn('Error taking photo', error);
});
}, [flash, hasFlash, action, translate, transactionID, updateScanAndNavigate, navigateToConfirmationStep, cameraPermissionStatus]);
}, [flash, hasFlash, action, translate, transactionID, updateScanAndNavigate, navigateToConfirmationStep, cameraPermissionStatus, didCapturePhoto]);

// Wait for camera permission status to render
if (cameraPermissionStatus == null) {
Expand Down

0 comments on commit 879378f

Please sign in to comment.