add "Cache" for hasFunds

This commit is contained in:
Matias Alejo Garcia 2016-10-15 09:41:35 -03:00
commit 0fbde71996
No known key found for this signature in database
GPG key ID: 02470DB551277AB3

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;
@ -113,6 +113,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
var updateHasFunds = function() { var updateHasFunds = function() {
$scope.hasFunds = true; $scope.hasFunds = true;
if ($rootScope.everHasFunds)
return;
var wallets = profileService.getWallets({ var wallets = profileService.getWallets({
onlyComplete: true, onlyComplete: true,
}); });
@ -134,6 +137,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
return; return;
} }
walletsTotalBalance = walletsTotalBalance + status.availableBalanceSat; walletsTotalBalance = walletsTotalBalance + status.availableBalanceSat;
if (walletsTotalBalance>0) {
$rootScope.everHasFunds = true;
}
if (index == wallets.length && walletsTotalBalance == 0) { if (index == wallets.length && walletsTotalBalance == 0) {
$scope.hasFunds = false; $scope.hasFunds = false;
$timeout(function() { $timeout(function() {