fix: update total balance on wallet page when WithdrawGroupFinished

This commit is contained in:
Sebastian 2022-03-15 10:35:00 -03:00
parent 984cbb7ab7
commit ae775d4b00
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1

View File

@ -52,20 +52,19 @@ export function HistoryPage({
goToWalletDeposit, goToWalletDeposit,
}: Props): VNode { }: Props): VNode {
const { i18n } = useTranslationContext(); const { i18n } = useTranslationContext();
const balance = useAsyncAsHook(wxApi.getBalance); const state = useAsyncAsHook(
const balanceWithoutError = balance?.hasError async () => ({
? [] b: await wxApi.getBalance(),
: balance?.response.balances || []; tx: await wxApi.getTransactions(),
}),
[NotificationType.WithdrawGroupFinished],
);
const transactionQuery = useAsyncAsHook(wxApi.getTransactions, [ if (!state) {
NotificationType.WithdrawGroupFinished,
]);
if (!transactionQuery || !balance) {
return <Loading />; return <Loading />;
} }
if (transactionQuery.hasError) { if (state.hasError) {
return ( return (
<LoadingError <LoadingError
title={ title={
@ -73,18 +72,18 @@ export function HistoryPage({
Could not load the list of transactions Could not load the list of transactions
</i18n.Translate> </i18n.Translate>
} }
error={transactionQuery} error={state}
/> />
); );
} }
return ( return (
<HistoryView <HistoryView
balances={balanceWithoutError} balances={state.response.b.balances}
defaultCurrency={currency} defaultCurrency={currency}
goToWalletManualWithdraw={goToWalletManualWithdraw} goToWalletManualWithdraw={goToWalletManualWithdraw}
goToWalletDeposit={goToWalletDeposit} goToWalletDeposit={goToWalletDeposit}
transactions={[...transactionQuery.response.transactions].reverse()} transactions={[...state.response.tx.transactions].reverse()}
/> />
); );
} }