From 65e6a8caa0de98632ad99cca35bf98bffe663dff Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 25 Apr 2022 22:37:41 -0300 Subject: useAsync new API --- .../taler-wallet-webextension/src/wallet/DeveloperPage.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx index a54c16754..c70850c6d 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx @@ -23,12 +23,12 @@ import { import { PendingTaskInfo } from "@gnu-taler/taler-wallet-core"; import { format } from "date-fns"; import { Fragment, h, VNode } from "preact"; -import { useRef, useState } from "preact/hooks"; +import { useEffect, useRef, useState } from "preact/hooks"; import { Diagnostics } from "../components/Diagnostics.js"; import { NotifyUpdateFadeOut } from "../components/styled/index.js"; import { Time } from "../components/Time.js"; import { useTranslationContext } from "../context/translation.js"; -import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { useAsyncAsHook2 } from "../hooks/useAsyncAsHook.js"; import { useDiagnostics } from "../hooks/useDiagnostics.js"; import * as wxApi from "../wxApi.js"; @@ -38,7 +38,7 @@ export function DeveloperPage(): VNode { const listenAllEvents = Array.from({ length: 1 }); listenAllEvents.includes = () => true; // includes every event - const response = useAsyncAsHook(async () => { + const response = useAsyncAsHook2(async () => { const op = await wxApi.getPendingOperations(); const c = await wxApi.dumpCoins(); const ex = await wxApi.listExchanges(); @@ -47,7 +47,13 @@ export function DeveloperPage(): VNode { coins: c.coins, exchanges: ex.exchanges, }; - }, listenAllEvents); + }); + + useEffect(() => { + wxApi.onUpdateNotification(listenAllEvents, () => { + response?.retry(); + }); + }); const nonResponse = { operations: [], coins: [], exchanges: [] }; const { operations, coins, exchanges } = -- cgit v1.2.3