diff --git a/src/components/QrScan.tsx b/src/components/QrScan.tsx index 1cb202cd..fd20ddaf 100644 --- a/src/components/QrScan.tsx +++ b/src/components/QrScan.tsx @@ -12,7 +12,7 @@ const QrScan = () => { let qrScanner: QrScanner; const { swapType, setInvoice, setOnchainAddress } = useCreateContext(); - const { t, camera, setCamera } = useGlobalContext(); + const { t, camera, notify, setCamera } = useGlobalContext(); const [scanning, setScanning] = createSignal(false); @@ -26,7 +26,6 @@ const QrScan = () => { }); const startScan = () => { - setScanning(true); if (qrScanner === undefined) { qrScanner = new QrScanner( qrRef, @@ -48,11 +47,21 @@ const QrScan = () => { }, ); } - qrScanner.start().then(); + qrScanner + .start() + .then(() => { + log.debug("qr scanner started"); + setScanning(true); + }) + .catch((err) => { + log.error("error starting qr scanner: ", err); + notify("error", t("error_starting_qr_scanner")); + }); }; const stopScan = () => { if (scanning()) { + log.debug("stopping qr scanner"); qrScanner.destroy(); setScanning(false); qrScanner = undefined; @@ -71,14 +80,14 @@ const QrScan = () => { {t("scan_qr_code")} - -
- - - X - -
-
+
+ + + X + +

diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index b3100e13..4ea4bd41 100644 --- a/src/i18n/i18n.ts +++ b/src/i18n/i18n.ts @@ -202,6 +202,8 @@ const dict = { reckless_mode_setting: "Reckless Mode", reckless_mode_setting_tooltip: "Disables prompts to download refund file and other confirmation steps", + error_starting_qr_scanner: + "Couldn't access camera, please check permissions!", }, de: { language: "Deutsch", @@ -414,6 +416,8 @@ const dict = { reckless_mode_setting: "Reckless Modus", reckless_mode_setting_tooltip: "Deaktiviert Downloadaufforderung der Rückerstattungsdatei und andere Bestätigungsschritte", + error_starting_qr_scanner: + "Konnte nicht auf Kamera zugreifen, bitte Berechtigungen überprüfen!", }, es: { language: "Español", @@ -626,6 +630,8 @@ const dict = { reckless_mode_setting: "Modo Reckless", reckless_mode_setting_tooltip: "Desactiva los avisos para descargar el archivo de reembolso y otros pasos de confirmación", + error_starting_qr_scanner: + "No se pudo acceder a la cámara, por favor compruebe los permisos!", }, zh: { language: "中文", @@ -812,6 +818,7 @@ const dict = { invalid_pair: "无效交换对", reckless_mode_setting: "鲁莽模式", reckless_mode_setting_tooltip: "禁用下载退款文件的提示和其他确认步骤", + error_starting_qr_scanner: "无法访问摄像头, 请检查权限!", }, };