Skip to content

Commit

Permalink
👌change naming
Browse files Browse the repository at this point in the history
  • Loading branch information
arunachalam-monk committed Aug 1, 2024
1 parent b7f18fa commit c7ddbe0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions packages/camera-web/src/Camera/hooks/useUserMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/camera-web/src/utils/errors.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
4 changes: 2 additions & 2 deletions packages/camera-web/test/Camera/hooks/useUserMedia.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit c7ddbe0

Please sign in to comment.