improve speed list

This commit is contained in:
Javier 2016-06-10 16:49:35 -03:00
parent 1524d26f10
commit 4df40c61bd
2 changed files with 32 additions and 22 deletions

View File

@ -2,11 +2,18 @@
ng-init="titleSection='Alternative Currency'; goBackToState = 'preferencesGlobal'; noColor = true">
</div>
<div class="content preferences" ng-controller="preferencesAltCurrencyController">
<div class="content preferences" ng-controller="preferencesAltCurrencyController" ng-init="init()">
<h4></h4>
<ion-radio class="line-b size-12 radio-label" ng-repeat="altCurrency in altCurrencyList" ng-value="altCurrency" ng-model="currentCurrency"
ng-click="save(altCurrency)">{{altCurrency.name}}
</ion-radio>
<ion-content>
<ion-radio class="line-b size-12 radio-label" ng-repeat="altCurrency in altCurrencyList" ng-value="altCurrency.isoCode" ng-model="currentCurrency"
ng-click="save(altCurrency)">{{altCurrency.name}}
</ion-radio>
<ion-infinite-scroll
ng-if="!listComplete"
on-infinite="loadMore()"
distance="1%">
</ion-infinite-scroll>
</ion-content>
</div>

View File

@ -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 = {