Commit d0c612cd authored by Guy Thouret's avatar Guy Thouret

(fix) Move the offset increment and don't exceed maximum possible offset in...

(fix) Move the offset increment and don't exceed maximum possible offset in FeaturedContentService.fetch() - #2190
1 merge request!629WIP: Fix duplicate boost posts appearing in newfeed
Pipeline #93544007 running with stages
import { Injectable } from '@angular/core';
import {
filter,
first,
map,
switchMap,
mergeMap,
skip,
take,
} from 'rxjs/operators';
import { filter, first, switchMap, mergeMap, skip, take } from 'rxjs/operators';
import { FeedsService } from '../../services/feeds.service';
@Injectable()
......@@ -23,8 +15,8 @@ export class FeaturedContentService {
}
async fetch() {
if (this.offset >= this.feedsService.rawFeed.getValue().length) {
this.offset = -1;
if (this.offset++ >= this.feedsService.rawFeed.getValue().length - 1) {
this.offset = 0;
}
// Refetch every 2 calls, if not loading
if (this.offset % 2 && !this.feedsService.inProgress.getValue()) {
......@@ -36,7 +28,7 @@ export class FeaturedContentService {
filter(feed => feed.length > 0),
first(),
mergeMap(feed => feed),
skip(this.offset++),
skip(this.offset),
take(1),
switchMap(async entity => {
if (!entity) {
......
Please register or to comment