fix repeated currencies
This commit is contained in:
parent
685a11cbfc
commit
6add7424de
2 changed files with 11 additions and 7 deletions
|
|
@ -19,15 +19,12 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
|||
var idx = lodash.indexBy(unusedCurrencyList, 'isoCode');
|
||||
var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode');
|
||||
|
||||
completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) {
|
||||
completeAlternativeList = lodash.reject(rateService.listAlternatives(true), function(c) {
|
||||
return idx[c.isoCode] || idx2[c.isoCode];
|
||||
});
|
||||
|
||||
completeAlternativeList = completeAlternativeList.sort(function(a, b) {
|
||||
return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1;
|
||||
});
|
||||
|
||||
$scope.altCurrencyList = completeAlternativeList.slice(0, 10);
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
|
|
@ -85,6 +82,7 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
|||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
var config = configService.getSync();
|
||||
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
|
||||
|
||||
storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) {
|
||||
$scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : [];
|
||||
init();
|
||||
|
|
|
|||
|
|
@ -111,18 +111,24 @@ RateService.prototype.fromFiat = function(amount, code) {
|
|||
return amount / this.getRate(code) * this.BTC_TO_SAT;
|
||||
};
|
||||
|
||||
RateService.prototype.listAlternatives = function() {
|
||||
RateService.prototype.listAlternatives = function(sort) {
|
||||
var self = this;
|
||||
if (!this.isAvailable()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return self.lodash.map(this.getAlternatives(), function(item) {
|
||||
var alternatives = self.lodash.map(this.getAlternatives(), function(item) {
|
||||
return {
|
||||
name: item.name,
|
||||
isoCode: item.isoCode
|
||||
}
|
||||
});
|
||||
if (sort) {
|
||||
alternatives.sort(function(a, b) {
|
||||
return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1;
|
||||
});
|
||||
}
|
||||
return self.lodash.uniq(alternatives, 'isoCode');
|
||||
};
|
||||
|
||||
angular.module('copayApp.services').factory('rateService', function($http, lodash) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue