You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
@@ -54,6 +54,14 @@ const Camera = (props: Props, ref: ForwardedRef<CameraRef>) => {
|
|||||||
logger.error(message);
|
logger.error(message);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const isReadyRef = useRef(false);
|
||||||
|
const onCameraReady = useCallback(() => {
|
||||||
|
if (isReadyRef.current) return; // Already emitted
|
||||||
|
|
||||||
|
isReadyRef.current = true;
|
||||||
|
props.onCameraReady();
|
||||||
|
}, [props.onCameraReady]);
|
||||||
|
|
||||||
useAsyncEffect(async (event) => {
|
useAsyncEffect(async (event) => {
|
||||||
// iOS issue workaround: Since upgrading to Expo SDK 52, closing and reopening the camera on iOS
|
// iOS issue workaround: Since upgrading to Expo SDK 52, closing and reopening the camera on iOS
|
||||||
// never emits onCameraReady. As a workaround, call .resumePreview and wait for it to resolve,
|
// never emits onCameraReady. As a workaround, call .resumePreview and wait for it to resolve,
|
||||||
@@ -63,16 +71,16 @@ const Camera = (props: Props, ref: ForwardedRef<CameraRef>) => {
|
|||||||
// Instead, wait for the preview to start using resumePreview:
|
// Instead, wait for the preview to start using resumePreview:
|
||||||
await camera.resumePreview();
|
await camera.resumePreview();
|
||||||
if (event.cancelled) return;
|
if (event.cancelled) return;
|
||||||
props.onCameraReady();
|
onCameraReady();
|
||||||
}
|
}
|
||||||
}, [camera, props.onCameraReady]);
|
}, [camera, onCameraReady]);
|
||||||
|
|
||||||
return hasPermission?.granted ? <CameraView
|
return hasPermission?.granted ? <CameraView
|
||||||
ref={setCamera}
|
ref={setCamera}
|
||||||
style={props.style}
|
style={props.style}
|
||||||
facing={props.cameraType === CameraDirection.Front ? 'front' : 'back'}
|
facing={props.cameraType === CameraDirection.Front ? 'front' : 'back'}
|
||||||
ratio={props.ratio as CameraRatio}
|
ratio={props.ratio as CameraRatio}
|
||||||
onCameraReady={Platform.OS === 'android' ? props.onCameraReady : undefined}
|
onCameraReady={onCameraReady}
|
||||||
onMountError={onMountError}
|
onMountError={onMountError}
|
||||||
animateShutter={false}
|
animateShutter={false}
|
||||||
barcodeScannerSettings={barcodeScannerSettings}
|
barcodeScannerSettings={barcodeScannerSettings}
|
||||||
|
|||||||
Reference in New Issue
Block a user