diff options
Diffstat (limited to 'packages/demobank-ui/src/context/wallet-integration.ts')
-rw-r--r-- | packages/demobank-ui/src/context/wallet-integration.ts | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/packages/demobank-ui/src/context/wallet-integration.ts b/packages/demobank-ui/src/context/wallet-integration.ts index 47bdc90ec..e14988ed1 100644 --- a/packages/demobank-ui/src/context/wallet-integration.ts +++ b/packages/demobank-ui/src/context/wallet-integration.ts @@ -14,47 +14,38 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { - stringifyTalerUri, - TalerUri -} from "@gnu-taler/taler-util"; -import { - ComponentChildren, - createContext, - h, - VNode -} from "preact"; +import { stringifyTalerUri, TalerUri } from "@gnu-taler/taler-util"; +import { ComponentChildren, createContext, h, VNode } from "preact"; import { useContext } from "preact/hooks"; /** * https://docs.taler.net/design-documents/039-taler-browser-integration.html - * - * @param uri + * + * @param uri */ function createHeadMetaTag(uri: TalerUri, onNotFound?: () => void) { - const meta = document.createElement("meta"); meta.setAttribute("name", "taler-uri"); meta.setAttribute("content", stringifyTalerUri(uri)); document.head.appendChild(meta); - let walletFound = false + let walletFound = false; window.addEventListener("beforeunload", () => { - walletFound = true - }) + walletFound = true; + }); setTimeout(() => { if (!walletFound && onNotFound) { - onNotFound() + onNotFound(); } - }, 10)//very short timeout + }, 10); //very short timeout } interface Type { /** * Tell the active wallet that an action is found - * - * @param uri - * @returns + * + * @param uri + * @returns */ publishTalerAction: (uri: TalerUri, onNotFound?: () => void) => void; } @@ -64,9 +55,13 @@ const Context = createContext<Type>(undefined); export const useTalerWalletIntegrationAPI = (): Type => useContext(Context); -export const TalerWalletIntegrationBrowserProvider = ({ children }: { children: ComponentChildren }): VNode => { +export const TalerWalletIntegrationBrowserProvider = ({ + children, +}: { + children: ComponentChildren; +}): VNode => { const value: Type = { - publishTalerAction: createHeadMetaTag + publishTalerAction: createHeadMetaTag, }; return h(Context.Provider, { value, @@ -74,7 +69,6 @@ export const TalerWalletIntegrationBrowserProvider = ({ children }: { children: }); }; - export const TalerWalletIntegrationTestingProvider = ({ children, value, @@ -82,7 +76,6 @@ export const TalerWalletIntegrationTestingProvider = ({ children: ComponentChildren; value: Type; }): VNode => { - return h(Context.Provider, { value, children, |