65528: last coll/subcom undefined fix (wait for remoteData.succeeded)

This commit is contained in:
Marie Verdonck
2019-10-11 11:06:25 +02:00
parent 514e9a98ed
commit 8e0280cb5a
2 changed files with 23 additions and 27 deletions

View File

@@ -1,10 +1,11 @@
import {Injectable} from '@angular/core';
import {Observable, of} from 'rxjs';
import {Observable} from 'rxjs';
import {CommunityDataService} from '../core/data/community-data.service';
import {PaginationComponentOptions} from '../shared/pagination/pagination-component-options.model';
import {SortDirection, SortOptions} from '../core/cache/models/sort-options.model';
import {take} from 'rxjs/operators';
import {Community} from '../core/shared/community.model';
import {RemoteData} from '../core/data/remote-data';
import {PaginatedList} from '../core/data/paginated-list';
@Injectable()
export class CommunityListService {
@@ -20,22 +21,14 @@ export class CommunityListService {
this.config.pageSize = 100;
this.config.currentPage = 1;
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
this.initTopCommunityList()
}
private initTopCommunityList(): void {
this.cds.findTop({
public getCommunityList(): Observable<RemoteData<PaginatedList<Community>>> {
return this.cds.findTop({
currentPage: this.config.currentPage,
elementsPerPage: this.config.pageSize,
sort: { field: this.sortConfig.field, direction: this.sortConfig.direction }
}).pipe(take(1)).subscribe((results) => {
this.communities = results.payload.page;
console.log('ping', this.communities);
});
}
public getCommunityList(): Observable<Community[]> {
return of(this.communities);
}
}