From f291dcb76648eeec2ec3051c7d43f19f56cf3728 Mon Sep 17 00:00:00 2001 From: Marvin Sextro Date: Sun, 25 Jul 2021 01:37:58 +0200 Subject: [PATCH] Differentiate camera access and permissions --- components/Form.tsx | 8 ++++++++ public/locales/en/errors.yml | 3 ++- public/locales/fi/errors.yml | 3 ++- public/locales/fr/errors.yml | 3 ++- public/locales/nl/errors.yml | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/Form.tsx b/components/Form.tsx index f7aa891..9e2932e 100644 --- a/components/Form.tsx +++ b/components/Form.tsx @@ -77,6 +77,14 @@ function Form(): JSX.Element { // Check access to camera device if (deviceList.length == 0) { + setErrorMessage("noCameraFound"); + return; + } + + // Check permissions to camera device + try { + navigator.mediaDevices.getUserMedia({video: true}); + } catch (e) { setErrorMessage("noCameraAccess"); return; } diff --git a/public/locales/en/errors.yml b/public/locales/en/errors.yml index fa84e11..cfea084 100644 --- a/public/locales/en/errors.yml +++ b/public/locales/en/errors.yml @@ -15,4 +15,5 @@ invalidQrCode: Invalid QR code certificateType: No valid certificate type found invalidTestResult: Invalid test result invalidTestType: Invalid test type -noCameraAccess: Could not access camera. Check permissions under Settings > Safari > Camera. \ No newline at end of file +noCameraAccess: Could not access camera. Check permissions under Settings > Safari > Camera. +noCameraFound: Could not find camera. \ No newline at end of file diff --git a/public/locales/fi/errors.yml b/public/locales/fi/errors.yml index 2ea9638..7159ffe 100644 --- a/public/locales/fi/errors.yml +++ b/public/locales/fi/errors.yml @@ -15,4 +15,5 @@ invalidQrCode: Virheellinen QR-koodi certificateType: Kelvollista varmennetyyppiä ei löytynyt invalidTestResult: Virheellinen testitulos invalidTestType: Virheellinen testityyppi -noCameraAccess: Kameraan ei päässyt käsiksi. Tarkista käyttöoikeudet kohdasta Asetukset > Safari > Kamera. \ No newline at end of file +noCameraAccess: Kameraan ei päässyt käsiksi. Tarkista käyttöoikeudet kohdasta Asetukset > Safari > Kamera. +noCameraFound: En löytänyt kameraa. \ No newline at end of file diff --git a/public/locales/fr/errors.yml b/public/locales/fr/errors.yml index cdf690e..4b6e6fc 100644 --- a/public/locales/fr/errors.yml +++ b/public/locales/fr/errors.yml @@ -15,4 +15,5 @@ invalidQrCode: QR Code non valide certificateType: Aucun type de certificat valide n'a été trouvé invalidTestResult: Résultat du test non valide invalidTestType: Type de test non valide -noCameraAccess: Impossible d'accéder à la caméra. Vérifiez les autorisations sous Paramètres > Safari > Appareil photo. \ No newline at end of file +noCameraAccess: Impossible d'accéder à la caméra. Vérifiez les autorisations sous Paramètres > Safari > Appareil photo. +noCameraFound: Impossible de trouver la caméra. \ No newline at end of file diff --git a/public/locales/nl/errors.yml b/public/locales/nl/errors.yml index 5b92d4a..cf7f86e 100644 --- a/public/locales/nl/errors.yml +++ b/public/locales/nl/errors.yml @@ -15,4 +15,5 @@ invalidQrCode: Ongeldige QR-code certificateType: Geen geldig certificaattype gevonden invalidTestResult: Ongeldig testresultaat invalidTestType: Ongeldig testtype -noCameraAccess: Kon geen toegang krijgen tot de camera. Controleer de machtigingen onder Instellingen > Safari > Camera. \ No newline at end of file +noCameraAccess: Kon geen toegang krijgen tot de camera. Controleer de machtigingen onder Instellingen > Safari > Camera. +noCameraFound: Ik kon de camera niet vinden. \ No newline at end of file