From 835d1724838de0e39c860ec57275fde4bf7b1a7c Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Thu, 18 Oct 2018 14:17:52 +0200 Subject: [PATCH] quickfix: update token balance on token added --- src/actions/TokenActions.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/actions/TokenActions.js b/src/actions/TokenActions.js index eea041e8..d0528ca1 100644 --- a/src/actions/TokenActions.js +++ b/src/actions/TokenActions.js @@ -56,14 +56,16 @@ export const setBalance = (tokenAddress: string, ethAddress: string, balance: st const newState: Array = [...getState().tokens]; const token: ?Token = newState.find(t => t.address === tokenAddress && t.ethAddress === ethAddress); if (token) { - token.loaded = true; - token.balance = balance; + const others = newState.filter(t => t !== token); + dispatch({ + type: TOKEN.SET_BALANCE, + payload: others.concat([{ + ...token, + loaded: true, + balance, + }]), + }); } - - dispatch({ - type: TOKEN.SET_BALANCE, - payload: newState, - }); }; export const add = (token: NetworkToken, account: Account): AsyncAction => async (dispatch: Dispatch): Promise => {