mirror of https://github.com/BTCPrivate/copay.git
debounce new testnet blocks notifications
This commit is contained in:
parent
583e0a560c
commit
466fceac80
|
@ -129,26 +129,13 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
|
|
||||||
wallet.on('notification', function(n) {
|
wallet.on('notification', function(n) {
|
||||||
|
|
||||||
$log.debug('BWC Notification:', n);
|
$log.debug('BWC Notification:', n);
|
||||||
|
|
||||||
// notification?
|
if (n.type == "NewBlock" && n.data.network == "testnet") {
|
||||||
|
throttledBwsEvent(n, wallet);
|
||||||
// TODO (put this in wallet ViewModel)
|
}
|
||||||
if (wallet.cachedStatus)
|
else newBwsEvent(n, wallet);
|
||||||
wallet.cachedStatus.isValid = false;
|
|
||||||
|
|
||||||
if (wallet.completeHistory)
|
|
||||||
wallet.completeHistory.isValid = false;
|
|
||||||
|
|
||||||
if (wallet.cachedActivity)
|
|
||||||
wallet.cachedActivity.isValid = false;
|
|
||||||
|
|
||||||
if (wallet.cachedTxps)
|
|
||||||
wallet.cachedTxps.isValid = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
wallet.on('walletCompleted', function() {
|
wallet.on('walletCompleted', function() {
|
||||||
|
@ -183,6 +170,26 @@ angular.module('copayApp.services')
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var throttledBwsEvent = lodash.throttle(function(n, wallet) {
|
||||||
|
newBwsEvent(n, wallet);
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
var newBwsEvent = function(n, wallet) {
|
||||||
|
if (wallet.cachedStatus)
|
||||||
|
wallet.cachedStatus.isValid = false;
|
||||||
|
|
||||||
|
if (wallet.completeHistory)
|
||||||
|
wallet.completeHistory.isValid = false;
|
||||||
|
|
||||||
|
if (wallet.cachedActivity)
|
||||||
|
wallet.cachedActivity.isValid = false;
|
||||||
|
|
||||||
|
if (wallet.cachedTxps)
|
||||||
|
wallet.cachedTxps.isValid = false;
|
||||||
|
|
||||||
|
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
||||||
|
};
|
||||||
|
|
||||||
var validationLock = false;
|
var validationLock = false;
|
||||||
|
|
||||||
root.runValidation = function(client, delay, retryDelay) {
|
root.runValidation = function(client, delay, retryDelay) {
|
||||||
|
|
Loading…
Reference in New Issue