Merge pull request #476 from matiu/feat/send-cache

Feat/send cache
This commit is contained in:
Jason Dreyzehner 2016-10-16 00:13:12 -04:00 committed by GitHub
commit 41b8547cf7

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService) { angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, $rootScope) {
var originalList; var originalList;
var CONTACTS_SHOW_LIMIT; var CONTACTS_SHOW_LIMIT;
@ -109,23 +109,26 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
}); });
}; };
var updateHasFunds = function() { var updateHasFunds = function() {
$scope.hasFunds = true;
if ($rootScope.everHasFunds) {
$scope.hasFunds = true;
return;
}
$scope.hasFunds = false;
var wallets = profileService.getWallets({ var wallets = profileService.getWallets({
onlyComplete: true, onlyComplete: true,
}); });
if (!wallets || !wallets.length) { if (!wallets || !wallets.length) {
$scope.hasFunds = false; return $timeout(function() {
$timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
} }
var index = 0; var index = 0;
var walletsTotalBalance = 0;
lodash.each(wallets, function(w) { lodash.each(wallets, function(w) {
walletService.getStatus(w, {}, function(err, status) { walletService.getStatus(w, {}, function(err, status) {
++index; ++index;
@ -133,9 +136,13 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$log.error(err); $log.error(err);
return; return;
} }
walletsTotalBalance = walletsTotalBalance + status.availableBalanceSat;
if (index == wallets.length && walletsTotalBalance == 0) { if (status.availableBalanceSat > 0) {
$scope.hasFunds = false; $scope.hasFunds = true;
$rootScope.everHasFunds = true;
}
if (index == wallets.length) {
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });