From 4df40c61bdc63f215f7829f0ad19dfa978191491 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 10 Jun 2016 16:49:35 -0300 Subject: [PATCH] improve speed list --- public/views/preferencesAltCurrency.html | 15 ++++++-- src/js/controllers/preferencesAltCurrency.js | 39 +++++++++++--------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/public/views/preferencesAltCurrency.html b/public/views/preferencesAltCurrency.html index 19d6ba26a..71bcd61a3 100644 --- a/public/views/preferencesAltCurrency.html +++ b/public/views/preferencesAltCurrency.html @@ -2,11 +2,18 @@ ng-init="titleSection='Alternative Currency'; goBackToState = 'preferencesGlobal'; noColor = true"> -
+

- {{altCurrency.name}} - + + {{altCurrency.name}} + + + +
diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index d14b80007..8ad0e9a06 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -1,29 +1,32 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', - function($scope, $log, configService, rateService, lodash, go, profileService, walletService) { + function($scope, $log, $timeout, configService, rateService, lodash, go, profileService, walletService) { var config = configService.getSync(); + var next = 10; + var completeAlternativeList; + $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; + $scope.listComplete = false; - $scope.currentCurrency = { - name: config.wallet.settings.alternativeName, - isoCode: config.wallet.settings.alternativeIsoCode + $scope.init = function() { + rateService.whenAvailable(function() { + completeAlternativeList = rateService.listAlternatives(); + lodash.remove(completeAlternativeList, function(c) { + return c.isoCode == 'BTC'; + }); + $scope.altCurrencyList = completeAlternativeList.slice(0, next); + }); }; - rateService.whenAvailable(function() { - $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; - }); - - $scope.$digest(); - }); + $scope.loadMore = function() { + $timeout(function() { + $scope.altCurrencyList = completeAlternativeList.slice(0, next); + next += 10; + $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; + $scope.$broadcast('scroll.infiniteScrollComplete'); + }, 100); + }; $scope.save = function(newAltCurrency) { var opts = {