From 65e6a8caa0de98632ad99cca35bf98bffe663dff Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 25 Apr 2022 22:37:41 -0300 Subject: useAsync new API --- .../src/wallet/History.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/History.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx index 51ffcb31a..cc99a8d0b 100644 --- a/packages/taler-wallet-webextension/src/wallet/History.tsx +++ b/packages/taler-wallet-webextension/src/wallet/History.tsx @@ -21,7 +21,7 @@ import { Transaction, } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; +import { useEffect, useState } from "preact/hooks"; import { Loading } from "../components/Loading.js"; import { LoadingError } from "../components/LoadingError.js"; import { @@ -35,7 +35,7 @@ import { import { Time } from "../components/Time.js"; import { TransactionItem } from "../components/TransactionItem.js"; import { useTranslationContext } from "../context/translation.js"; -import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { useAsyncAsHook2 } from "../hooks/useAsyncAsHook.js"; import { NoBalanceHelp } from "../popup/NoBalanceHelp.js"; import * as wxApi from "../wxApi.js"; @@ -50,13 +50,16 @@ export function HistoryPage({ goToWalletDeposit, }: Props): VNode { const { i18n } = useTranslationContext(); - const state = useAsyncAsHook( - async () => ({ - b: await wxApi.getBalance(), - tx: await wxApi.getTransactions(), - }), - [NotificationType.WithdrawGroupFinished], - ); + const state = useAsyncAsHook2(async () => ({ + b: await wxApi.getBalance(), + tx: await wxApi.getTransactions(), + })); + + useEffect(() => { + wxApi.onUpdateNotification([NotificationType.WithdrawGroupFinished], () => { + state?.retry(); + }); + }); if (!state) { return ; -- cgit v1.2.3