updates hasFunds

This commit is contained in:
Matias Alejo Garcia 2016-10-11 18:13:46 -03:00
commit a661b5bc58
No known key found for this signature in database
GPG key ID: 02470DB551277AB3

View file

@ -6,7 +6,6 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
var CONTACTS_SHOW_LIMIT; var CONTACTS_SHOW_LIMIT;
var currentContactsPage; var currentContactsPage;
$scope.hasFunds = false;
var updateList = function() { var updateList = function() {
CONTACTS_SHOW_LIMIT = 10; CONTACTS_SHOW_LIMIT = 10;
@ -105,11 +104,43 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
}); });
}; };
var updateHasFunds = function() {
$scope.hasFunds = null;
var wallets = profileService.getWallets({
onlyComplete: true,
});
if (!wallets || !wallets.length) {
$scope.hasFunds = false;
}
var index = 0;
lodash.each(wallets, function(w) {
walletService.getStatus(w, {}, function(err, status) {
++index;
if (err || !status) {
$log.error(err);
return;
}
if (status.availableBalanceSat) {
$scope.hasFunds = true;
}
if (index == wallets.length) {
$scope.hasFunds = $scope.hasFunds || false;
}
});
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.formData = { $scope.formData = {
search: null search: null
}; };
updateList(); updateList();
updateHasFunds();
}); });
}); });