diff options
author | Sebastian <sebasjm@gmail.com> | 2022-03-15 10:35:00 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-03-15 10:35:00 -0300 |
commit | ae775d4b00011874ac13f2a9fdf96e99b547f977 (patch) | |
tree | 5c7dfb6b9c64a049440a851e41d9a51b0fa55cda | |
parent | 984cbb7ab79b50eab38bb6a05ab56ccc278ac835 (diff) |
fix: update total balance on wallet page when WithdrawGroupFinished
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/History.tsx | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx index ea6057d05..02fc0a76c 100644 --- a/packages/taler-wallet-webextension/src/wallet/History.tsx +++ b/packages/taler-wallet-webextension/src/wallet/History.tsx @@ -52,20 +52,19 @@ export function HistoryPage({ goToWalletDeposit, }: Props): VNode { const { i18n } = useTranslationContext(); - const balance = useAsyncAsHook(wxApi.getBalance); - const balanceWithoutError = balance?.hasError - ? [] - : balance?.response.balances || []; - - const transactionQuery = useAsyncAsHook(wxApi.getTransactions, [ - NotificationType.WithdrawGroupFinished, - ]); + const state = useAsyncAsHook( + async () => ({ + b: await wxApi.getBalance(), + tx: await wxApi.getTransactions(), + }), + [NotificationType.WithdrawGroupFinished], + ); - if (!transactionQuery || !balance) { + if (!state) { return <Loading />; } - if (transactionQuery.hasError) { + if (state.hasError) { return ( <LoadingError title={ @@ -73,18 +72,18 @@ export function HistoryPage({ Could not load the list of transactions </i18n.Translate> } - error={transactionQuery} + error={state} /> ); } return ( <HistoryView - balances={balanceWithoutError} + balances={state.response.b.balances} defaultCurrency={currency} goToWalletManualWithdraw={goToWalletManualWithdraw} goToWalletDeposit={goToWalletDeposit} - transactions={[...transactionQuery.response.transactions].reverse()} + transactions={[...state.response.tx.transactions].reverse()} /> ); } |