diff --git a/js/controllers/homeWallet.js b/js/controllers/homeWallet.js index 32ad7680a..2dcc6e0a2 100644 --- a/js/controllers/homeWallet.js +++ b/js/controllers/homeWallet.js @@ -2,13 +2,9 @@ angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $modal, controllerUtils) { + controllerUtils.redirIfNotComplete(); - $rootScope.title = 'Home'; - if ($rootScope.addrInfos) { - $scope.address = $rootScope.addrInfos[0]; - } - } ); diff --git a/js/controllers/paymentIntent.js b/js/controllers/paymentIntent.js index 5ed73853a..846111383 100644 --- a/js/controllers/paymentIntent.js +++ b/js/controllers/paymentIntent.js @@ -2,7 +2,7 @@ var bitcore = require('bitcore'); -angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, controllerUtils) { +angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, controllerUtils) { $scope.wallets = []; @@ -10,7 +10,13 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun _.each(wids, function(wid) { var w = $rootScope.iden.getWalletById(wid); if (w && w.isReady()) { + $scope.wallets.push(w); + controllerUtils.clearBalanceCache(w); + controllerUtils.updateBalance(w, function() { + $rootScope.$digest(); + }, true); + } }); @@ -24,10 +30,6 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun } } }); - - modalInstance.result.then(function(selectedItem) {}, function() { - $rootScope.pendingPayment = null; - }); }; @@ -35,16 +37,16 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun // It is not the same as the $modal service used above. var ModalInstanceCtrl = function($scope, $modalInstance, items, controllerUtils) { - $scope.wallets = items; - $scope.ok = function(selectedItem) { controllerUtils.setPaymentWallet(selectedItem); $modalInstance.close(); }; $scope.cancel = function() { - $modalInstance.dismiss('cancel'); + $rootScope.pendingPayment = null; + $location.path('/'); + $modalInstance.close(); }; }; diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index eff844cfe..52b37c4c9 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -289,13 +289,13 @@ angular.module('copayApp.services') if (cb) return cb(); }; - root.updateBalance = function(w, cb) { + root.updateBalance = function(w, cb, refreshAll) { w = w || $rootScope.wallet; if (!w) return root.onErrorDigest(); if (!w.isReady()) return; w.balanceInfo = {}; - var scope = root.isFocusedWallet(w.id) ? $rootScope : w.balanceInfo; + var scope = root.isFocusedWallet(w.id) && !refreshAll ? $rootScope : w.balanceInfo; root.updateAddressList(); @@ -303,7 +303,7 @@ angular.module('copayApp.services') if (_balanceCache[wid]) { root._updateScope(w, _balanceCache[wid], scope, function() { - if (root.isFocusedWallet(w.id)) { + if (root.isFocusedWallet(w.id) && !refreshAll) { setTimeout(function() { $rootScope.$digest(); }, 1); diff --git a/views/homeWallet.html b/views/homeWallet.html index f566788fd..5183b835c 100644 --- a/views/homeWallet.html +++ b/views/homeWallet.html @@ -37,15 +37,15 @@

Quick receive

- +
-

{{address.addressStr}}

+

{{$root.addrInfos[0].addressStr}}

-