From 87a6e28eeaea6c9634042016f222a993805f70f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 14 Dec 2016 09:33:23 -0300 Subject: [PATCH] fix empty list in android devices --- src/js/controllers/preferencesAltCurrency.js | 28 +++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 5f5b83a6e..a60e6cbee 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -3,23 +3,19 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', function($scope, $log, $timeout, $ionicHistory, configService, rateService, lodash, profileService, walletService, storageService) { - var next = 10; - var completeAlternativeList; - - var unusedCurrencyList = [{ - isoCode: 'LTL' - }, { - isoCode: 'BTC' - }]; - function init() { + var unusedCurrencyList = [{ + isoCode: 'LTL' + }, { + isoCode: 'BTC' + }]; var config = configService.getSync(); + $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; - rateService.whenAvailable(function() { - storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { - - $scope.lastUsedAltCurrencyList = JSON.parse(lastUsedAltCurrency) || []; + storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { + $scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : []; + rateService.whenAvailable(function() { var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); @@ -66,10 +62,12 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl function saveLastUsed(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'); storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {}); }; - init(); + $scope.$on("$ionicView.beforeEnter", function(event, data) { + init(); + }); });