txHistory cache

This commit is contained in:
Matias Alejo Garcia 2016-08-22 22:10:46 -03:00
commit 240e26a783
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
3 changed files with 86 additions and 24 deletions

View file

@ -6,12 +6,14 @@ angular.module('copayApp.controllers').controller('tabHomeController',
self.glideraEnabled = configService.getSync().glidera.enabled;
self.setWallets = function() {
$scope.wallets = profileService.getWallets();
};
var setPendingTxps = function(txps) {
$scope.txps = lodash.sort(txps, function(x) {
return walletId;
});
};
var formatPendingTxps = function(txps) {
$scope.pendingTxProposalsCountForUs = 0;
var now = Math.floor(Date.now() / 1000);
@ -65,18 +67,17 @@ angular.module('copayApp.controllers').controller('tabHomeController',
if (!tx.deleteLockTime)
tx.canBeRemoved = true;
if (tx.creatorId != tx.wallet.copayerId) {
$scope.pendingTxProposalsCountForUs = $scope.pendingTxProposalsCountForUs + 1;
}
});
$scope.txps = txps;
return txps;
};
self.updateAllClients = function() {
self.updateAllWallets = function() {
$scope.wallets = profileService.getWallets();
var txps = [];
var i = $scope.wallets.length;
lodash.each($scope.wallets, function(wallet) {
walletService.getStatus(wallet, {}, function(err, status) {
if (err) {
@ -87,6 +88,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
txps = txps.concat(status.pendingTxps);
}
if (--i == 0) {
txps = formatPendingTxps(txps);
setPendingTxps(txps);
}
wallet.status = status;
@ -94,11 +96,33 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
}
self.setWallets();
self.updateAllClients();
self.updateWallet = function(wallet) {
var txps = lodash.filter($scope.txps, function(x) {
return x.walletId != wallet.id;
});
walletService.getStatus(wallet, {}, function(err, status) {
if (err) {
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
return;
} // TODO
if (status.pendingTxps && status.pendingTxps[0]) {
txps = txps.concat(status.pendingTxps);
txps = formatPendingTxps(txps);
setPendingTxps(txps);
}
wallet.status = status;
});
};
self.updateAllWallets();
$scope.bitpayCardEnabled = true; // TODO
$scope.$on('$destroy', function() {});
var config = configService.getSync().wallet;
var GLIDERA_LOCK_TIME = 6 * 60 * 60;