1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-30 20:28:09 +00:00

quickfix: update token balance on token added

This commit is contained in:
Szymon Lesisz 2018-10-18 14:17:52 +02:00
parent a9883727f3
commit 835d172483

View File

@ -56,14 +56,16 @@ export const setBalance = (tokenAddress: string, ethAddress: string, balance: st
const newState: Array<Token> = [...getState().tokens]; const newState: Array<Token> = [...getState().tokens];
const token: ?Token = newState.find(t => t.address === tokenAddress && t.ethAddress === ethAddress); const token: ?Token = newState.find(t => t.address === tokenAddress && t.ethAddress === ethAddress);
if (token) { if (token) {
token.loaded = true; const others = newState.filter(t => t !== token);
token.balance = balance;
}
dispatch({ dispatch({
type: TOKEN.SET_BALANCE, type: TOKEN.SET_BALANCE,
payload: newState, payload: others.concat([{
...token,
loaded: true,
balance,
}]),
}); });
}
}; };
export const add = (token: NetworkToken, account: Account): AsyncAction => async (dispatch: Dispatch): Promise<void> => { export const add = (token: NetworkToken, account: Account): AsyncAction => async (dispatch: Dispatch): Promise<void> => {