Fix balances update (#4077)
* Fix balances fetching * Fix fetching balances while syncing
This commit is contained in:
parent
40f0ee004f
commit
e1847442cc
@ -86,7 +86,7 @@ export default class Balances {
|
||||
// If syncing, only retrieve balances once every
|
||||
// few seconds
|
||||
if (syncing) {
|
||||
this.shortThrottledFetch();
|
||||
this.shortThrottledFetch.cancel();
|
||||
return this.longThrottledFetch();
|
||||
}
|
||||
|
||||
|
@ -173,18 +173,15 @@ export function fetchTokens (_tokenIds) {
|
||||
export function fetchBalances (_addresses) {
|
||||
return (dispatch, getState) => {
|
||||
const { api, personal } = getState();
|
||||
const { visibleAccounts, accountsInfo } = personal;
|
||||
const { visibleAccounts, accounts } = personal;
|
||||
|
||||
const addresses = uniq((_addresses || visibleAccounts || []).concat(Object.keys(accountsInfo)));
|
||||
|
||||
if (addresses.length === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const addresses = uniq(_addresses || visibleAccounts || []);
|
||||
|
||||
// With only a single account, more info will be displayed.
|
||||
const fullFetch = addresses.length === 1;
|
||||
|
||||
const addressesToFetch = uniq(addresses);
|
||||
// Add accounts addresses (for notifications, accounts selection, etc.)
|
||||
const addressesToFetch = uniq(addresses.concat(Object.keys(accounts)));
|
||||
|
||||
return Promise
|
||||
.all(addressesToFetch.map((addr) => fetchAccount(addr, api, fullFetch)))
|
||||
|
@ -218,6 +218,7 @@ export default class CertificationsMiddleware {
|
||||
const _addresses = action.addresses || [];
|
||||
addresses = uniq(addresses.concat(_addresses));
|
||||
fetchConfirmedEvents();
|
||||
next(action);
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@ -122,7 +122,7 @@ export function setVisibleAccounts (addresses) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(fetchBalances(addresses));
|
||||
dispatch(_setVisibleAccounts(addresses));
|
||||
dispatch(fetchBalances(addresses));
|
||||
};
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export default handleActions({
|
||||
setVisibleAccounts (state, action) {
|
||||
const addresses = (action.addresses || []).sort();
|
||||
|
||||
if (isEqual(addresses, state.addresses)) {
|
||||
if (isEqual(addresses, state.visibleAccounts)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user