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:
parent
a9883727f3
commit
835d172483
@ -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({
|
||||||
|
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<void> => {
|
export const add = (token: NetworkToken, account: Account): AsyncAction => async (dispatch: Dispatch): Promise<void> => {
|
||||||
|
Loading…
Reference in New Issue
Block a user