perf: Make getCameraPermission and getMicrophonePermission synchronous (#2302)

This commit is contained in:
Marc Rousavy
2023-12-19 14:22:04 +01:00
committed by GitHub
parent 3d2feb6f6c
commit 591cf30a06
8 changed files with 28 additions and 66 deletions

View File

@@ -31,7 +31,7 @@ type Props = NativeStackScreenProps<Routes, 'CameraPage'>
export function CameraPage({ navigation }: Props): React.ReactElement {
const camera = useRef<Camera>(null)
const [isCameraInitialized, setIsCameraInitialized] = useState(false)
const [hasMicrophonePermission, setHasMicrophonePermission] = useState(false)
const hasMicrophonePermission = useMemo(() => Camera.getMicrophonePermissionStatus() === 'granted', [])
const zoom = useSharedValue(0)
const isPressingButton = useSharedValue(false)
@@ -131,10 +131,6 @@ export function CameraPage({ navigation }: Props): React.ReactElement {
// Run everytime the neutralZoomScaled value changes. (reset zoom when device changes)
zoom.value = neutralZoom
}, [neutralZoom, zoom])
useEffect(() => {
Camera.getMicrophonePermissionStatus().then((status) => setHasMicrophonePermission(status === 'granted'))
}, [])
//#endregion
//#region Pinch to Zoom Gesture