Commit 46e4e01f authored by Guy Thouret's avatar Guy Thouret

(fix) Increment on each fetch call, only test for offset reset and fetch next...

(fix) Increment on each fetch call, only test for offset reset and fetch next after waiting for entity to resolve - #2190
1 merge request!629WIP: Fix duplicate boost posts appearing in newfeed
Pipeline #94324351 running with stages
......@@ -24,27 +24,34 @@ export class FeaturedContentService {
}
async fetch() {
console.log('fetch()');
return await this.feedsService.feed
.pipe(
filter(entities => entities.length > 0),
mergeMap(feed => feed), // Convert feed array to stream
skip(this.offset),
skip(this.offset++),
take(1),
switchMap(async entity => {
if (!entity) {
return false;
} else {
if (this.offset++ >= this.maximumOffset) {
this.offset = 0;
this.fetchNextFeed();
}
return await entity.pipe(first()).toPromise();
const resolvedEntity = await entity.pipe(first()).toPromise();
console.log(entity);
this.resetOffsetAtEndOfStream();
return resolvedEntity;
}
})
)
.toPromise();
}
protected resetOffsetAtEndOfStream() {
if (this.offset >= this.maximumOffset) {
this.offset = 0;
this.fetchNextFeed();
}
}
protected fetchNextFeed() {
if (!this.feedsService.inProgress.getValue()) {
this.feedsService.clear();
......
Please register or to comment