From e9bb85a212dbd9b86875e89a0aca5d805e2ad61b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 13 Aug 2021 18:04:05 -0300 Subject: new wallet UI and more tests --- .../src/hooks/useDiagnostics.ts | 29 ++++++++++++++++++++++ .../src/hooks/useTalerActionURL.ts | 8 ++---- 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 packages/taler-wallet-webextension/src/hooks/useDiagnostics.ts (limited to 'packages/taler-wallet-webextension/src/hooks') diff --git a/packages/taler-wallet-webextension/src/hooks/useDiagnostics.ts b/packages/taler-wallet-webextension/src/hooks/useDiagnostics.ts new file mode 100644 index 000000000..e2c62f998 --- /dev/null +++ b/packages/taler-wallet-webextension/src/hooks/useDiagnostics.ts @@ -0,0 +1,29 @@ +import { WalletDiagnostics } from "@gnu-taler/taler-util"; +import { useEffect, useState } from "preact/hooks"; +import * as wxApi from "../wxApi"; + +export function useDiagnostics(): [WalletDiagnostics | undefined, boolean] { + const [timedOut, setTimedOut] = useState(false); + const [diagnostics, setDiagnostics] = useState( + undefined + ); + + useEffect(() => { + let gotDiagnostics = false; + setTimeout(() => { + if (!gotDiagnostics) { + console.error("timed out"); + setTimedOut(true); + } + }, 1000); + const doFetch = async (): Promise => { + const d = await wxApi.getDiagnostics(); + console.log("got diagnostics", d); + gotDiagnostics = true; + setDiagnostics(d); + }; + console.log("fetching diagnostics"); + doFetch(); + }, []); + return [diagnostics, timedOut] +} \ No newline at end of file diff --git a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts index b884ca943..1c8504a8e 100644 --- a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts +++ b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts @@ -57,12 +57,8 @@ function makeExtensionUrlWithParams( ): string { const innerUrl = new URL(chrome.extension.getURL("/" + url)); if (params) { - for (const key in params) { - const p = params[key]; - if (p) { - innerUrl.searchParams.set(key, p); - } - } + const hParams = Object.keys(params).map(k => `${k}=${params[k]}`).join('&') + innerUrl.hash = innerUrl.hash + '?' + hParams } return innerUrl.href; } -- cgit v1.2.3