refactor wallet seletors in buy/sell controllers

This commit is contained in:
Matias Alejo Garcia 2016-06-11 23:55:28 -03:00
commit 4b0abd77a2
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
9 changed files with 73 additions and 119 deletions

View file

@ -5,31 +5,17 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
var self = this;
var fc;
var otherWallets = function(testnet) {
var network = testnet ? 'testnet' : 'livenet';
return lodash.filter(profileService.getWallets(network), function(w) {
return w.network == network;
});
};
this.init = function(testnet) {
self.otherWallets = otherWallets(testnet);
// Choose focused wallet
try {
var currentWalletId = profileService.focusedClient.credentials.walletId;
lodash.find(self.otherWallets, function(w) {
if (w.id == currentWalletId) {
$timeout(function() {
self.selectedWalletId = w.id;
self.selectedWalletName = w.name;
fc = profileService.getClient(w.id);
$scope.$apply();
}, 100);
}
});
} catch (e) {
$log.debug(e);
};
self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1)
client = profileService.focusedClient;
if (client) {
$timeout(function() {
self.selectedWalletId = client.credentials.walletId;
self.selectedWalletName = client.credentials.walletName;
$scope.$apply();
}, 100);
}
};
this.getPaymentMethods = function(token) {