diff --git a/packages/camera-web/src/Camera/hooks/useUserMedia.ts b/packages/camera-web/src/Camera/hooks/useUserMedia.ts index 4233ace08..64f1b95b7 100644 --- a/packages/camera-web/src/Camera/hooks/useUserMedia.ts +++ b/packages/camera-web/src/Camera/hooks/useUserMedia.ts @@ -38,13 +38,13 @@ class InvalidStreamError extends Error { export enum UserMediaErrorType { /** * The camera stream couldn't be fetched because the web page does not have the permissions to access the camera. - * if both webpage and browser permissions are denied, this error will be returned. + * If both webpage and browser permissions are denied, this error will be returned. */ - NOT_ALLOWED_WEBPAGE = 'not_allowed_webpage', + WEBPAGE_NOT_ALLOWED = 'not_allowed_webpage', /** * The camera stream couldn't be fetched because the browser does not support the `getUserMedia` function. */ - NOT_ALLOWED_BROWSER = 'not_allowed_browser', + BROWSER_NOT_ALLOWED = 'not_allowed_browser', /** * The camera stream couldn't be fetched because the web page does not have the permissions to access the camera. */ @@ -206,7 +206,7 @@ export function useUserMedia( const { handleError } = useMonitoring(); const isActive = useRef(true); - let cameraPermissionState: PermissionStatus['state'] | null = null; + let cameraPermissionState: PermissionState | null = null; useEffect(() => { return () => { isActive.current = false; @@ -218,10 +218,10 @@ export function useUserMedia( if (err instanceof Error && err.name === 'NotAllowedError') { switch (cameraPermissionState) { case 'denied': - type = UserMediaErrorType.NOT_ALLOWED_WEBPAGE; + type = UserMediaErrorType.WEBPAGE_NOT_ALLOWED; break; case 'granted': - type = UserMediaErrorType.NOT_ALLOWED_BROWSER; + type = UserMediaErrorType.BROWSER_NOT_ALLOWED; break; default: type = UserMediaErrorType.NOT_ALLOWED; diff --git a/packages/camera-web/src/utils/errors.utils.ts b/packages/camera-web/src/utils/errors.utils.ts index 9a299a853..3295a2b78 100644 --- a/packages/camera-web/src/utils/errors.utils.ts +++ b/packages/camera-web/src/utils/errors.utils.ts @@ -14,14 +14,14 @@ export function getCameraErrorLabel(error?: UserMediaErrorType): TranslationObje de: 'Die Kameravorschau ist nicht verfügbar, da für die Seite kein Kamerazugriff gewährt wurde.', nl: 'De cameravoorbeeld is niet beschikbaar omdat er geen toegang tot de camera is verleend aan de pagina.', }; - case UserMediaErrorType.NOT_ALLOWED_WEBPAGE: + case UserMediaErrorType.WEBPAGE_NOT_ALLOWED: return { en: 'Unable to get camera access. Make sure to press “Allow” when asked to grant camera permission for this web page.', fr: "Impossible d'accéder à la caméra. Veuillez vous assurer d'appuyer sur “Autoriser” lorsqu'on vous propose d'autoriser l'accès à la caméra pour cette page web.", de: 'Die Kamera kann nicht zugelassen werden. Stellen Sie sicher, dass Sie auf „Zulassen“ drücken, wenn Sie aufgefordert werden, die Kamera für diese Webseite zuzulassen.', nl: 'Kan geen toestemming krijgen voor de camera. Zorg ervoor dat u op “Toestaan” drukt wanneer u wordt gevraagd om toestemming te geven voor het gebruik van de camera op deze webpagina.', }; - case UserMediaErrorType.NOT_ALLOWED_BROWSER: + case UserMediaErrorType.BROWSER_NOT_ALLOWED: return { en: "Unable to get camera access. Make sure to grant camera access to your current internet browser in your device's settings.", fr: "Impossible d'accéder à la caméra. Veuillez vous assurer d'autoriser l'accès à la caméra pour ce navigateur internet dans les paramètres de votre téléphone.", diff --git a/packages/camera-web/test/Camera/hooks/useUserMedia.test.ts b/packages/camera-web/test/Camera/hooks/useUserMedia.test.ts index 9ff83c562..d18c6e1c0 100644 --- a/packages/camera-web/test/Camera/hooks/useUserMedia.test.ts +++ b/packages/camera-web/test/Camera/hooks/useUserMedia.test.ts @@ -146,7 +146,7 @@ describe('useUserMedia hook', () => { stream: null, dimensions: null, error: { - type: UserMediaErrorType.NOT_ALLOWED_BROWSER, + type: UserMediaErrorType.BROWSER_NOT_ALLOWED, nativeError, }, isLoading: false, @@ -171,7 +171,7 @@ describe('useUserMedia hook', () => { stream: null, dimensions: null, error: { - type: UserMediaErrorType.NOT_ALLOWED_WEBPAGE, + type: UserMediaErrorType.WEBPAGE_NOT_ALLOWED, nativeError, }, isLoading: false,