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,7 +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 { environment } from 'src/environments/environment ' ;
26+ import { AppConfig , APP_CONFIG } from 'src/config/app-config.interface ' ;
2727
2828// Helper method to combine an flatten an array of observables of flatNode arrays
2929export const combineAndFlatten = ( obsList : Observable < FlatNode [ ] > [ ] ) : Observable < FlatNode [ ] > =>
@@ -81,17 +81,22 @@ const communityListStateSelector = (state: AppState) => state.communityList;
8181const expandedNodesSelector = createSelector ( communityListStateSelector , ( communityList : CommunityListState ) => communityList . expandedNodes ) ;
8282const loadingNodeSelector = createSelector ( communityListStateSelector , ( communityList : CommunityListState ) => communityList . loadingNode ) ;
8383
84- export const MAX_COMCOLS_PER_PAGE = environment . browseCommunities . communityListPageSize ;
85-
8684/**
8785 * Service class for the community list, responsible for the creating of the flat list used by communityList dataSource
8886 * and connection to the store to retrieve and save the state of the community list
8987 */
9088@Injectable ( )
9189export class CommunityListService {
9290
93- constructor ( private communityDataService : CommunityDataService , private collectionDataService : CollectionDataService ,
94- 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 ;
95100 }
96101
97102 private configOnePage : FindListOptions = Object . assign ( new FindListOptions ( ) , {
@@ -146,7 +151,7 @@ export class CommunityListService {
146151 private getTopCommunities ( options : FindListOptions ) : Observable < PaginatedList < Community > > {
147152 return this . communityDataService . findTop ( {
148153 currentPage : options . currentPage ,
149- elementsPerPage : MAX_COMCOLS_PER_PAGE ,
154+ elementsPerPage : this . pageSize ,
150155 sort : {
151156 field : options . sort . field ,
152157 direction : options . sort . direction
@@ -217,7 +222,7 @@ export class CommunityListService {
217222 let subcoms = [ ] ;
218223 for ( let i = 1 ; i <= currentCommunityPage ; i ++ ) {
219224 const nextSetOfSubcommunitiesPage = this . communityDataService . findByParent ( community . uuid , {
220- elementsPerPage : MAX_COMCOLS_PER_PAGE ,
225+ elementsPerPage : this . pageSize ,
221226 currentPage : i
222227 } ,
223228 followLink ( 'subcommunities' , { findListOptions : this . configOnePage } ) ,
@@ -242,7 +247,7 @@ export class CommunityListService {
242247 let collections = [ ] ;
243248 for ( let i = 1 ; i <= currentCollectionPage ; i ++ ) {
244249 const nextSetOfCollectionsPage = this . collectionDataService . findByParent ( community . uuid , {
245- elementsPerPage : MAX_COMCOLS_PER_PAGE ,
250+ elementsPerPage : this . pageSize ,
246251 currentPage : i
247252 } )
248253 . pipe (
0 commit comments