11/* eslint-disable max-classes-per-file */
2- import { Injectable } from '@angular/core' ;
2+ import { Inject , Injectable } from '@angular/core' ;
33import { createSelector , Store } from '@ngrx/store' ;
44
55import { combineLatest as observableCombineLatest , Observable , of as observableOf } from 'rxjs' ;
@@ -23,6 +23,7 @@ import { followLink } from '../shared/utils/follow-link-config.model';
2323import { FlatNode } from './flat-node.model' ;
2424import { ShowMoreFlatNode } from './show-more-flat-node.model' ;
2525import { FindListOptions } from '../core/data/find-list-options.model' ;
26+ import { AppConfig , APP_CONFIG } from 'src/config/app-config.interface' ;
2627
2728// Helper method to combine an flatten an array of observables of flatNode arrays
2829export const combineAndFlatten = ( obsList : Observable < FlatNode [ ] > [ ] ) : Observable < FlatNode [ ] > =>
@@ -80,17 +81,22 @@ const communityListStateSelector = (state: AppState) => state.communityList;
8081const expandedNodesSelector = createSelector ( communityListStateSelector , ( communityList : CommunityListState ) => communityList . expandedNodes ) ;
8182const loadingNodeSelector = createSelector ( communityListStateSelector , ( communityList : CommunityListState ) => communityList . loadingNode ) ;
8283
83- export const MAX_COMCOLS_PER_PAGE = 20 ;
84-
8584/**
8685 * Service class for the community list, responsible for the creating of the flat list used by communityList dataSource
8786 * and connection to the store to retrieve and save the state of the community list
8887 */
8988@Injectable ( )
9089export class CommunityListService {
9190
92- constructor ( private communityDataService : CommunityDataService , private collectionDataService : CollectionDataService ,
93- private store : Store < any > ) {
91+ private pageSize : number ;
92+
93+ constructor (
94+ @Inject ( APP_CONFIG ) protected appConfig : AppConfig ,
95+ private communityDataService : CommunityDataService ,
96+ private collectionDataService : CollectionDataService ,
97+ private store : Store < any >
98+ ) {
99+ this . pageSize = appConfig . communityList . pageSize ;
94100 }
95101
96102 private configOnePage : FindListOptions = Object . assign ( new FindListOptions ( ) , {
@@ -145,7 +151,7 @@ export class CommunityListService {
145151 private getTopCommunities ( options : FindListOptions ) : Observable < PaginatedList < Community > > {
146152 return this . communityDataService . findTop ( {
147153 currentPage : options . currentPage ,
148- elementsPerPage : MAX_COMCOLS_PER_PAGE ,
154+ elementsPerPage : this . pageSize ,
149155 sort : {
150156 field : options . sort . field ,
151157 direction : options . sort . direction
@@ -216,7 +222,7 @@ export class CommunityListService {
216222 let subcoms = [ ] ;
217223 for ( let i = 1 ; i <= currentCommunityPage ; i ++ ) {
218224 const nextSetOfSubcommunitiesPage = this . communityDataService . findByParent ( community . uuid , {
219- elementsPerPage : MAX_COMCOLS_PER_PAGE ,
225+ elementsPerPage : this . pageSize ,
220226 currentPage : i
221227 } ,
222228 followLink ( 'subcommunities' , { findListOptions : this . configOnePage } ) ,
@@ -241,7 +247,7 @@ export class CommunityListService {
241247 let collections = [ ] ;
242248 for ( let i = 1 ; i <= currentCollectionPage ; i ++ ) {
243249 const nextSetOfCollectionsPage = this . collectionDataService . findByParent ( community . uuid , {
244- elementsPerPage : MAX_COMCOLS_PER_PAGE ,
250+ elementsPerPage : this . pageSize ,
245251 currentPage : i
246252 } )
247253 . pipe (
0 commit comments