refresh balance instantly if cache hit
This commit is contained in:
parent
8acb4d6676
commit
0ff67f69ef
1 changed files with 6 additions and 3 deletions
|
|
@ -245,7 +245,7 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.updateBalance = function(w, cb) {
|
root.updateBalance = function(w, cb) {
|
||||||
var updateScope = function(w, data, cb2) {
|
function updateScope(w, data, cb2) {
|
||||||
var satToUnit = 1 / w.settings.unitToSatoshi;
|
var satToUnit = 1 / w.settings.unitToSatoshi;
|
||||||
var COIN = bitcore.util.COIN;
|
var COIN = bitcore.util.COIN;
|
||||||
|
|
||||||
|
|
@ -269,7 +269,6 @@ angular.module('copayApp.services')
|
||||||
balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit;
|
balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit;
|
||||||
}
|
}
|
||||||
$rootScope.balanceByAddr = balanceByAddr;
|
$rootScope.balanceByAddr = balanceByAddr;
|
||||||
root.updateAddressList();
|
|
||||||
|
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
$rootScope.totalBalanceAlternative = rateService.toFiat(balanceSat, w.settings.alternativeIsoCode);
|
$rootScope.totalBalanceAlternative = rateService.toFiat(balanceSat, w.settings.alternativeIsoCode);
|
||||||
|
|
@ -289,11 +288,15 @@ angular.module('copayApp.services')
|
||||||
if (!w.isReady()) return;
|
if (!w.isReady()) return;
|
||||||
console.log('## Updating balance of:' + w.id)
|
console.log('## Updating balance of:' + w.id)
|
||||||
|
|
||||||
|
root.updateAddressList();
|
||||||
|
|
||||||
var wid = w.getId();
|
var wid = w.getId();
|
||||||
|
|
||||||
if (_balanceCache[wid]) {
|
if (_balanceCache[wid]) {
|
||||||
updateScope(w, _balanceCache[wid]);
|
updateScope(w, _balanceCache[wid]);
|
||||||
|
setTimeout(function() {
|
||||||
|
$rootScope.$digest();
|
||||||
|
}, 1);
|
||||||
} else {
|
} else {
|
||||||
$rootScope.updatingBalance = true;
|
$rootScope.updatingBalance = true;
|
||||||
}
|
}
|
||||||
|
|
@ -309,7 +312,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
updateScope(w, _balanceCache[wid], function() {
|
updateScope(w, _balanceCache[wid], function() {
|
||||||
$rootScope.updatingBalance = false;
|
$rootScope.updatingBalance = false;
|
||||||
cb();
|
if (cb) cb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue