Merge pull request #4345 from JDonadio/bug/select-currency
Fix currency selection
This commit is contained in:
commit
c5eb9a60fd
2 changed files with 19 additions and 44 deletions
|
|
@ -1,39 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
|
||||
function($scope, $timeout, $log, configService, rateService, lodash, go, profileService, walletService) {
|
||||
this.hideAdv = true;
|
||||
this.hidePriv = true;
|
||||
this.hideSecret = true;
|
||||
this.error = null;
|
||||
this.success = null;
|
||||
function($scope, $log, configService, rateService, lodash, go, profileService, walletService) {
|
||||
|
||||
var config = configService.getSync();
|
||||
|
||||
this.selectedAlternative = {
|
||||
$scope.currentCurrency = {
|
||||
name: config.wallet.settings.alternativeName,
|
||||
isoCode: config.wallet.settings.alternativeIsoCode
|
||||
};
|
||||
|
||||
this.alternativeOpts = [this.selectedAlternative]; //default value
|
||||
|
||||
var self = this;
|
||||
rateService.whenAvailable(function() {
|
||||
self.alternativeOpts = rateService.listAlternatives();
|
||||
lodash.remove(self.alternativeOpts, function(n) {
|
||||
return n.isoCode == 'BTC';
|
||||
$scope.altCurrencyList = rateService.listAlternatives();
|
||||
|
||||
lodash.remove($scope.altCurrencyList, function(c) {
|
||||
return c.isoCode == 'BTC';
|
||||
});
|
||||
|
||||
lodash.each($scope.altCurrencyList, function(altCurrency) {
|
||||
if (config.wallet.settings.alternativeIsoCode === altCurrency.isoCode)
|
||||
$scope.currentCurrency = altCurrency;
|
||||
});
|
||||
|
||||
for (var ii in self.alternativeOpts) {
|
||||
if (config.wallet.settings.alternativeIsoCode === self.alternativeOpts[ii].isoCode) {
|
||||
self.selectedAlternative = self.alternativeOpts[ii];
|
||||
}
|
||||
}
|
||||
$scope.$digest();
|
||||
});
|
||||
|
||||
|
||||
this.save = function(newAltCurrency) {
|
||||
$scope.save = function(newAltCurrency) {
|
||||
var opts = {
|
||||
wallet: {
|
||||
settings: {
|
||||
|
|
@ -42,23 +34,14 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
|||
}
|
||||
}
|
||||
};
|
||||
this.selectedAlternative = {
|
||||
name: newAltCurrency.name,
|
||||
isoCode: newAltCurrency.isoCode,
|
||||
};
|
||||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.warn(err);
|
||||
go.preferencesGlobal();
|
||||
$scope.$emit('Local/UnitSettingUpdated');
|
||||
walletService.updateRemotePreferences(profileService.walletClients, {}, function() {
|
||||
walletService.updateRemotePreferences(profileService.getClients(), {}, function() {
|
||||
$log.debug('Remote preferences saved');
|
||||
});
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue