alt currency list now puts the top 10 fiat and recently used at top
This commit is contained in:
parent
a92a4b7a16
commit
4df7b245a4
2 changed files with 32 additions and 5 deletions
|
|
@ -6,11 +6,30 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
||||||
var next = 10;
|
var next = 10;
|
||||||
var completeAlternativeList = [];
|
var completeAlternativeList = [];
|
||||||
|
|
||||||
|
var popularCurrencyList = [
|
||||||
|
{isoCode: 'USD', order: 0},
|
||||||
|
{isoCode: 'EUR', order: 1},
|
||||||
|
{isoCode: 'JPY', order: 2},
|
||||||
|
{isoCode: 'GBP', order: 3},
|
||||||
|
{isoCode: 'AUD', order: 4},
|
||||||
|
{isoCode: 'CAD', order: 5},
|
||||||
|
{isoCode: 'CHF', order: 6},
|
||||||
|
{isoCode: 'CNY', order: 7},
|
||||||
|
{isoCode: 'KRW', order: 8},
|
||||||
|
{isoCode: 'HKD', order: 9},
|
||||||
|
]
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
var unusedCurrencyList = [{
|
var unusedCurrencyList = [{
|
||||||
isoCode: 'LTL'
|
isoCode: 'LTL'
|
||||||
}, {
|
}, {
|
||||||
isoCode: 'BTC'
|
isoCode: 'BTC'
|
||||||
|
}, {
|
||||||
|
isoCode: 'BCC'
|
||||||
|
}, {
|
||||||
|
isoCode: 'BCH_BTC'
|
||||||
|
}, {
|
||||||
|
isoCode: 'BCH'
|
||||||
}];
|
}];
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
|
|
||||||
|
|
@ -18,12 +37,20 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
||||||
|
|
||||||
var idx = lodash.indexBy(unusedCurrencyList, 'isoCode');
|
var idx = lodash.indexBy(unusedCurrencyList, 'isoCode');
|
||||||
var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode');
|
var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode');
|
||||||
|
var idx3 = lodash.indexBy(popularCurrencyList, 'isoCode');
|
||||||
|
var alternatives = rateService.listAlternatives(true);
|
||||||
|
|
||||||
completeAlternativeList = lodash.reject(rateService.listAlternatives(true), function(c) {
|
lodash.each(alternatives, function(c) {
|
||||||
return idx[c.isoCode] || idx2[c.isoCode];
|
if (idx3[c.isoCode]) {
|
||||||
|
idx3[c.isoCode].name = c.name;
|
||||||
|
}
|
||||||
|
if (!idx[c.isoCode] && !idx2[c.isoCode] && !idx3[c.isoCode]) {
|
||||||
|
completeAlternativeList.push(c);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.altCurrencyList = completeAlternativeList.slice(0, 10);
|
$scope.altCurrencyList = completeAlternativeList.slice(0, 10);
|
||||||
|
$scope.lastUsedPopularList = lodash.unique(lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList), 'isoCode');
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
placeholder="{{'Search your currency' | translate}}">
|
placeholder="{{'Search your currency' | translate}}">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="list" ng-if="lastUsedAltCurrencyList[0]">
|
<div class="list" ng-if="lastUsedPopularList[0]">
|
||||||
<ion-radio class="alt-currency-radio" ng-repeat="lastUsedAltCurrency in lastUsedAltCurrencyList" ng-value="lastUsedAltCurrency.isoCode" ng-model="currentCurrency"
|
<ion-radio class="alt-currency-radio" ng-repeat="lastUsedAltCurrency in lastUsedPopularList" ng-value="lastUsedAltCurrency.isoCode" ng-model="currentCurrency"
|
||||||
ng-click="save(lastUsedAltCurrency)">{{lastUsedAltCurrency.name}} <span class="item-note">{{lastUsedAltCurrency.isoCode}}</span>
|
ng-click="save(lastUsedAltCurrency)">{{lastUsedAltCurrency.name}} <span class="item-note">{{lastUsedAltCurrency.isoCode}}</span>
|
||||||
</ion-radio>
|
</ion-radio>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue