From 07893f4ace9f8407e34d69a23f08c3b18f8c7210 Mon Sep 17 00:00:00 2001 From: pycckuu Date: Thu, 5 Jan 2023 13:55:55 +0800 Subject: [PATCH] fix(dapp): update balances after redeeming action Without this patch, the balances in the balance card are not updated after redeeming rewards. Instead, a user manually refreshes the page or hits the refresh button to see the updated balance. This patch solves the problem by dispatching update balance actions after confirming the redemption transaction. --- .../SecondStageRedeem/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dapp/src/components/ZAssets/PrivateZAssetsTable/RedeemRewardsWarningDialog/SecondStageRedeem/index.tsx b/dapp/src/components/ZAssets/PrivateZAssetsTable/RedeemRewardsWarningDialog/SecondStageRedeem/index.tsx index dacdd96a..071d6fab 100644 --- a/dapp/src/components/ZAssets/PrivateZAssetsTable/RedeemRewardsWarningDialog/SecondStageRedeem/index.tsx +++ b/dapp/src/components/ZAssets/PrivateZAssetsTable/RedeemRewardsWarningDialog/SecondStageRedeem/index.tsx @@ -34,7 +34,9 @@ import { StartWalletActionPayload, } from 'redux/slices/ui/web3-wallet-last-action'; import {updateUTXOStatus} from 'redux/slices/wallet/advanced-stakes-rewards'; +import {getChainBalance} from 'redux/slices/wallet/chain-balance'; import {poolV0ExitDelaySelector} from 'redux/slices/wallet/poolV0'; +import {getZkpTokenBalance} from 'redux/slices/wallet/zkp-token-balance'; import {parseTxErrorMessage} from 'services/errors'; import {generateRootKeypairs} from 'services/keys'; import {exit} from 'services/pool'; @@ -157,6 +159,8 @@ export default function SecondStageRedeem(props: { reward.id, UTXOStatus.SPENT, ]); + dispatch(getZkpTokenBalance, context); + dispatch(getChainBalance, context); openNotification( 'Withdrawal completed successfully', @@ -169,7 +173,7 @@ export default function SecondStageRedeem(props: { 'info', 10000, ); - }, [dispatch, library, account, chainId, reward]); + }, [dispatch, library, account, chainId, reward, context]); useEffect(() => { const timer = setInterval(() => { @@ -267,8 +271,9 @@ export default function SecondStageRedeem(props: { {isLockPeriodPassed ? ( Redeem {zZKP} ZKP