diff --git a/src/components/QrScan.tsx b/src/components/QrScan.tsx index 4d3e90b6..f6f7d5dd 100644 --- a/src/components/QrScan.tsx +++ b/src/components/QrScan.tsx @@ -12,16 +12,14 @@ const QrScan = () => { let qrScanner: QrScanner; const { swapType, setInvoice, setOnchainAddress } = useCreateContext(); - const { t, camera, notify, setCamera } = useGlobalContext(); + const { t, notify } = useGlobalContext(); + const [camera, setCamera] = createSignal(false); const [scanning, setScanning] = createSignal(false); onMount(async () => { const hasCamera = await QrScanner.hasCamera(); - log.debug("detecting camera: ", hasCamera); - if (!hasCamera) { - return; - } + log.debug("Has camera to scan QR codes:", hasCamera); setCamera(hasCamera); }); diff --git a/src/context/Global.tsx b/src/context/Global.tsx index 6aaceac9..9db53cc3 100644 --- a/src/context/Global.tsx +++ b/src/context/Global.tsx @@ -48,8 +48,6 @@ export type GlobalContextType = { setNotificationType: Setter; webln: Accessor; setWebln: Setter; - camera: Accessor; - setCamera: Setter; ref: Accessor; setRef: Setter; i18nConfigured: Accessor; @@ -124,7 +122,6 @@ const GlobalProvider = (props: { children: JSX.Element }) => { const [notificationType, setNotificationType] = createSignal(""); const [webln, setWebln] = createSignal(false); - const [camera, setCamera] = createSignal(false); const [embedded, setEmbedded] = createSignal(false); @@ -377,8 +374,6 @@ const GlobalProvider = (props: { children: JSX.Element }) => { setNotificationType, webln, setWebln, - camera, - setCamera, ref, setRef, i18nConfigured, diff --git a/src/pages/Create.tsx b/src/pages/Create.tsx index 62b78429..d3c5bd6a 100644 --- a/src/pages/Create.tsx +++ b/src/pages/Create.tsx @@ -403,7 +403,7 @@ const Create = () => { - + diff --git a/tests/components/QrScan.spec.tsx b/tests/components/QrScan.spec.tsx deleted file mode 100644 index 3bbd1d29..00000000 --- a/tests/components/QrScan.spec.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { render, screen } from "@solidjs/testing-library"; - -import QrScan from "../../src/components/QrScan"; -import { TestComponent, contextWrapper, globalSignals } from "../helper"; - -describe("QrScan", () => { - test("should render the QrScan component", async () => { - render( - () => ( - <> - - - - ), - { wrapper: contextWrapper }, - ); - globalSignals.setCamera(true); - const button = await screen.findByText(globalSignals.t("scan_qr_code")); - expect(button).not.toBeUndefined(); - }); -});