performance improvements

This commit is contained in:
Gabriel Bazán 2016-12-14 09:48:36 -03:00
commit f515e24b57

View file

@ -9,12 +9,6 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
}, { }, {
isoCode: 'BTC' isoCode: 'BTC'
}]; }];
var config = configService.getSync();
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) {
$scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : [];
rateService.whenAvailable(function() { rateService.whenAvailable(function() {
var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); var idx = lodash.indexBy(unusedCurrencyList, 'isoCode');
@ -24,6 +18,8 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
return idx[c.isoCode] || idx2[c.isoCode]; return idx[c.isoCode] || idx2[c.isoCode];
}); });
$scope.altCurrencyList = $scope.completeAlternativeList; $scope.altCurrencyList = $scope.completeAlternativeList;
$timeout(function() {
$scope.$apply();
}); });
}); });
} }
@ -62,12 +58,25 @@ 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, 3);
$scope.lastUsedAltCurrencyList = lodash.uniq($scope.lastUsedAltCurrencyList, 'isoCode'); $scope.lastUsedAltCurrencyList = lodash.uniq($scope.lastUsedAltCurrencyList, 'isoCode');
$scope.lastUsedAltCurrencyList = $scope.lastUsedAltCurrencyList.slice(0, 3);
storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {}); storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {});
}; };
$scope.$on("$ionicView.beforeEnter", function(event, data) { $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) : [];
$timeout(function() {
$scope.$apply();
});
});
});
$scope.$on("$ionicView.enter", function(event, data) {
$timeout(function() {
init(); init();
}); });
}); });
});