refactor getWallet in profile

Signed-off-by: Matias Alejo Garcia <ematiu@gmail.com>
This commit is contained in:
Matias Alejo Garcia 2015-06-19 21:33:27 -03:00
commit 707acfaf64
3 changed files with 50 additions and 32 deletions

View file

@ -38,24 +38,7 @@ angular.module('copayApp.controllers').controller('paymentUriController',
};
this.getWallets = function(network) {
if (!profileService.profile) return;
var config = configService.getSync();
config.colorFor = config.colorFor || {};
config.aliasFor = config.aliasFor || {};
var ret = lodash.map(profileService.profile.credentials, function(c) {
return {
m: c.m,
n: c.n,
name: config.aliasFor[c.walletId] || c.walletName,
id: c.walletId,
network: c.network,
color: config.colorFor[c.walletId] || '#2C3E50'
};
});
ret = lodash.filter(ret, function(w) {
return (w.network == network);
});
return lodash.sortBy(ret, 'name');
return profileService.getWallets(network);
};
this.selectWallet = function(wid) {

View file

@ -396,5 +396,29 @@ angular.module('copayApp.services')
});
};
root.getWallets = function(network) {
if (!root.profile) return [];
var config = configService.getSync();
config.colorFor = config.colorFor || {};
config.aliasFor = config.aliasFor || {};
var ret = lodash.map(root.profile.credentials, function(c) {
return {
m: c.m,
n: c.n,
name: config.aliasFor[c.walletId] || c.walletName,
id: c.walletId,
network: c.network,
color: config.colorFor[c.walletId] || '#2C3E50'
};
});
ret = lodash.filter(ret, function(w) {
return (w.network == network);
});
return lodash.sortBy(ret, 'name');
};
return root;
});