aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/reducer.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-13 07:28:54 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-13 09:09:28 +0800
commit711b307e6c56457647a98c6d76725aa90ac0d53e (patch)
treeb49ec5b525aa22299f05eb8c0a1930cb7d085aa5 /packages/instant/src/redux/reducer.ts
parent1ab19a7c23eb1bb252c50d6dbe323d62aad61154 (diff)
downloaddexon-sol-tools-711b307e6c56457647a98c6d76725aa90ac0d53e.tar
dexon-sol-tools-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.gz
dexon-sol-tools-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.bz2
dexon-sol-tools-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.lz
dexon-sol-tools-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.xz
dexon-sol-tools-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.zst
dexon-sol-tools-711b307e6c56457647a98c6d76725aa90ac0d53e.zip
feat: prevent eth balance blink
Diffstat (limited to 'packages/instant/src/redux/reducer.ts')
-rw-r--r--packages/instant/src/redux/reducer.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 4688250bc..28f094184 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -73,11 +73,16 @@ export const createReducer = (initialState: State) => {
case ActionTypes.SET_ACCOUNT_STATE_LOCKED:
return reduceStateWithAccount(state, LOCKED_ACCOUNT);
case ActionTypes.SET_ACCOUNT_STATE_READY: {
- const account: AccountReady = {
+ const address = action.data;
+ const newAccount: AccountReady = {
state: AccountState.Ready,
- address: action.data,
+ address,
};
- return reduceStateWithAccount(state, account);
+ const currentAccount = state.providerState.account;
+ if (currentAccount.state === AccountState.Ready && currentAccount.address === address) {
+ newAccount.ethBalanceInWei = currentAccount.ethBalanceInWei;
+ }
+ return reduceStateWithAccount(state, newAccount);
}
case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE: {
const { address, ethBalanceInWei } = action.data;