diff options
author | Sebastian <sebasjm@gmail.com> | 2022-04-25 22:37:41 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-04-26 11:48:28 -0300 |
commit | 65e6a8caa0de98632ad99cca35bf98bffe663dff (patch) | |
tree | 53bd9ec1c376e9cb73c57ba4ce223899c0b0751e /packages/taler-wallet-webextension/src/popup/BalancePage.tsx | |
parent | 1e6b2dd150416d4acfac4cf4068c41edb036d5e0 (diff) | |
download | wallet-core-65e6a8caa0de98632ad99cca35bf98bffe663dff.tar.xz |
useAsync new API
Diffstat (limited to 'packages/taler-wallet-webextension/src/popup/BalancePage.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/popup/BalancePage.tsx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx index 37000bd38..d67e44346 100644 --- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx +++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx @@ -16,7 +16,7 @@ import { Amounts, Balance, NotificationType } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; +import { useEffect, useState } from "preact/hooks"; import { BalanceTable } from "../components/BalanceTable.js"; import { JustInDevMode } from "../components/JustInDevMode.js"; import { Loading } from "../components/Loading.js"; @@ -24,7 +24,7 @@ import { LoadingError } from "../components/LoadingError.js"; import { MultiActionButton } from "../components/MultiActionButton.js"; import { ButtonBoxPrimary, ButtonPrimary } from "../components/styled/index.js"; import { useTranslationContext } from "../context/translation.js"; -import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { useAsyncAsHook2 } from "../hooks/useAsyncAsHook.js"; import { AddNewActionView } from "../wallet/AddNewActionView.js"; import * as wxApi from "../wxApi.js"; import { NoBalanceHelp } from "./NoBalanceHelp.js"; @@ -41,9 +41,14 @@ export function BalancePage({ }: Props): VNode { const { i18n } = useTranslationContext(); const [addingAction, setAddingAction] = useState(false); - const state = useAsyncAsHook(wxApi.getBalance, [ - NotificationType.WithdrawGroupFinished, - ]); + const state = useAsyncAsHook2(wxApi.getBalance); + + useEffect(() => { + wxApi.onUpdateNotification([NotificationType.WithdrawGroupFinished], () => { + state?.retry(); + }); + }); + const balances = !state || state.hasError ? [] : state.response.balances; if (!state) { |