From 212656130f67ee8dcc19fa5e641990f57a96668a Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Tue, 4 Nov 2014 17:18:15 -0300 Subject: [PATCH 1/5] Update balance of wallets --- js/controllers/paymentIntent.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/controllers/paymentIntent.js b/js/controllers/paymentIntent.js index 5ed73853a..e2ae6b294 100644 --- a/js/controllers/paymentIntent.js +++ b/js/controllers/paymentIntent.js @@ -11,6 +11,9 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun var w = $rootScope.iden.getWalletById(wid); if (w && w.isReady()) { $scope.wallets.push(w); + controllerUtils.updateBalance(w, function() { + $rootScope.$digest(); + }); } }); From 0c9b36032b356c77d55ab39f218803050a720898 Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Wed, 5 Nov 2014 16:37:25 -0300 Subject: [PATCH 2/5] Update balance of wallets --- js/controllers/homeWallet.js | 6 +----- js/controllers/paymentIntent.js | 14 ++++++++------ views/homeWallet.html | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) 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 e2ae6b294..47d418146 100644 --- a/js/controllers/paymentIntent.js +++ b/js/controllers/paymentIntent.js @@ -11,9 +11,11 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun var w = $rootScope.iden.getWalletById(wid); if (w && w.isReady()) { $scope.wallets.push(w); + controllerUtils.clearBalanceCache(w); controllerUtils.updateBalance(w, function() { $rootScope.$digest(); }); + } }); @@ -28,9 +30,9 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun } }); - modalInstance.result.then(function(selectedItem) {}, function() { - $rootScope.pendingPayment = null; - }); + // modalInstance.result.then(function(selectedItem) {}, function() { + // $rootScope.pendingPayment = null; + // }); }; @@ -38,16 +40,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; + controllerUtils.setFocusedWallet($scope.wallets[0]); + $modalInstance.close(); }; }; 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}}

-
From d13600a4f5da2c2099d3e6fee45548f46ab285a9 Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Thu, 6 Nov 2014 10:32:47 -0300 Subject: [PATCH 3/5] Deleting commented lines --- js/controllers/paymentIntent.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/js/controllers/paymentIntent.js b/js/controllers/paymentIntent.js index 47d418146..42f1f30fe 100644 --- a/js/controllers/paymentIntent.js +++ b/js/controllers/paymentIntent.js @@ -29,10 +29,6 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun } } }); - - // modalInstance.result.then(function(selectedItem) {}, function() { - // $rootScope.pendingPayment = null; - // }); }; From bef1113fc326dcc52a0394c4273bbd4342a68e6a Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Thu, 6 Nov 2014 11:17:05 -0300 Subject: [PATCH 4/5] Go to the actual wallet --- js/controllers/paymentIntent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/controllers/paymentIntent.js b/js/controllers/paymentIntent.js index 42f1f30fe..9aa47f15e 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 = []; @@ -44,7 +44,7 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun $scope.cancel = function() { $rootScope.pendingPayment = null; - controllerUtils.setFocusedWallet($scope.wallets[0]); + $location.path('/'); $modalInstance.close(); }; }; From be10694763d1bc52e7992a7c29880710cda081fc Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Thu, 6 Nov 2014 12:47:54 -0300 Subject: [PATCH 5/5] Update balance to every wallet --- js/controllers/paymentIntent.js | 3 ++- js/services/controllerUtils.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/controllers/paymentIntent.js b/js/controllers/paymentIntent.js index 9aa47f15e..846111383 100644 --- a/js/controllers/paymentIntent.js +++ b/js/controllers/paymentIntent.js @@ -10,11 +10,12 @@ 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); } }); 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);