Merge pull request #1727 from matiaspando/feature/selectWalletOnBIP21

Feature/select wallet on bip21
This commit is contained in:
Gustavo Maximiliano Cortez 2014-11-06 14:30:52 -03:00
commit b2aef7c7db
4 changed files with 17 additions and 19 deletions

View file

@ -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];
}
}
);

View file

@ -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();
};
};

View file

@ -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);