fix empty list in android devices
This commit is contained in:
parent
6aedf9a75f
commit
87a6e28eea
1 changed files with 13 additions and 15 deletions
|
|
@ -3,23 +3,19 @@
|
||||||
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
|
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
|
||||||
function($scope, $log, $timeout, $ionicHistory, configService, rateService, lodash, profileService, walletService, storageService) {
|
function($scope, $log, $timeout, $ionicHistory, configService, rateService, lodash, profileService, walletService, storageService) {
|
||||||
|
|
||||||
var next = 10;
|
|
||||||
var completeAlternativeList;
|
|
||||||
|
|
||||||
var unusedCurrencyList = [{
|
|
||||||
isoCode: 'LTL'
|
|
||||||
}, {
|
|
||||||
isoCode: 'BTC'
|
|
||||||
}];
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
var unusedCurrencyList = [{
|
||||||
|
isoCode: 'LTL'
|
||||||
|
}, {
|
||||||
|
isoCode: 'BTC'
|
||||||
|
}];
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
|
|
||||||
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
|
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
|
||||||
|
|
||||||
rateService.whenAvailable(function() {
|
storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) {
|
||||||
storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) {
|
$scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : [];
|
||||||
|
rateService.whenAvailable(function() {
|
||||||
$scope.lastUsedAltCurrencyList = JSON.parse(lastUsedAltCurrency) || [];
|
|
||||||
|
|
||||||
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');
|
||||||
|
|
@ -66,10 +62,12 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
||||||
|
|
||||||
function saveLastUsed(newAltCurrency) {
|
function saveLastUsed(newAltCurrency) {
|
||||||
$scope.lastUsedAltCurrencyList.unshift(newAltCurrency);
|
$scope.lastUsedAltCurrencyList.unshift(newAltCurrency);
|
||||||
$scope.lastUsedAltCurrencyList = $scope.lastUsedAltCurrencyList.slice(0, 5);
|
$scope.lastUsedAltCurrencyList = $scope.lastUsedAltCurrencyList.slice(0, 3);
|
||||||
$scope.lastUsedAltCurrencyList = lodash.uniq($scope.lastUsedAltCurrencyList, 'isoCode');
|
$scope.lastUsedAltCurrencyList = lodash.uniq($scope.lastUsedAltCurrencyList, 'isoCode');
|
||||||
storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {});
|
storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {});
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
|
init();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue