From 3a5f303ec68d9a26f6da0ee68322cf5a5141309a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 12 Apr 2024 10:50:35 -0300 Subject: remove clear button --- .../src/wallet/QrReader.tsx | 139 +++++++++------------ 1 file changed, 62 insertions(+), 77 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/QrReader.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/QrReader.tsx b/packages/taler-wallet-webextension/src/wallet/QrReader.tsx index 1d18b3993..d36524cc4 100644 --- a/packages/taler-wallet-webextension/src/wallet/QrReader.tsx +++ b/packages/taler-wallet-webextension/src/wallet/QrReader.tsx @@ -25,14 +25,14 @@ import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { css } from "@linaria/core"; import { styled } from "@linaria/react"; import jsQR, * as pr from "jsqr"; -import { Fragment, h, VNode } from "preact"; +import { h, VNode } from "preact"; import { useRef, useState } from "preact/hooks"; +import { EnabledBySettings } from "../components/EnabledBySettings.js"; import { Alert } from "../mui/Alert.js"; import { Button } from "../mui/Button.js"; import { Grid } from "../mui/Grid.js"; import { InputFile } from "../mui/InputFile.js"; import { TextField } from "../mui/TextField.js"; -import { EnabledBySettings } from "../components/EnabledBySettings.js"; const QrCanvas = css` width: 80%; @@ -185,7 +185,7 @@ async function createCanvasFromFile( canvas.width = img.width; canvas.height = img.height; return new Promise((ok, bad) => { - img.addEventListener("load", (e) => { + img.addEventListener("load", () => { try { const code = drawIntoCanvasAndGetQR(img, canvas); ok(code); @@ -197,7 +197,7 @@ async function createCanvasFromFile( } async function waitUntilReady(video: HTMLVideoElement): Promise { - return new Promise((ok, bad) => { + return new Promise((ok, _bad) => { if (video.readyState === video.HAVE_ENOUGH_DATA) { return ok(); } @@ -215,14 +215,14 @@ export function QrReaderPage({ onDetected }: Props): VNode { const { i18n } = useTranslationContext(); function onChangeDetect(str: string) { - if (!!str) { - const uri = parseTalerUri(str) + if (str) { + const uri = parseTalerUri(str); if (!uri) { setError( i18n.str`URI is not valid. Taler URI should start with "taler://"`, ); } else { - onDetected(uri) + onDetected(uri); setError(undefined); } } else { @@ -232,7 +232,7 @@ export function QrReaderPage({ onDetected }: Props): VNode { } function onChange(str: string) { - if (!!str) { + if (str) { if (!parseTalerUri(str)) { setError( i18n.str`URI is not valid. Taler URI should start with "taler://"`, @@ -295,7 +295,6 @@ export function QrReaderPage({ onDetected }: Props): VNode { } const uri = parseTalerUri(value); - const active = value === ""; return (
@@ -304,84 +303,70 @@ export function QrReaderPage({ onDetected }: Props): VNode { Scan a QR code or enter taler:// URI below - -

- -

+
+
+ +
+ {uri && ( + + )} +

{error && {error}}

- {uri && ( - - - - )} - +

- {!active && ( - -

- - -

-
- )} Read QR from file -- cgit v1.2.3