Skip to content

Commit

Permalink
fix(discover): 🐛 Fixed up the discover lists,
Browse files Browse the repository at this point in the history
Handle the exception from using the internal API, improve the loading so it shouldn't 'step back'. Also fixed where it would only load a small number of items and wouldn't load any more
  • Loading branch information
tidusjar committed Sep 16, 2021
1 parent 99c7289 commit fc69158
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class CarouselListComponent implements OnInit {
let currentIteration = 0;
while (this.discoverResults.length <= 14 && currentIteration <= 3) {
currentIteration++;
await this.loadData();
await this.loadData(false);
}
}

Expand All @@ -155,7 +155,11 @@ export class CarouselListComponent implements OnInit {
public async newPage() {
// Note this is using the internal carousel APIs
// https://github.com/primefaces/primeng/blob/master/src/app/components/carousel/carousel.ts
var end = this.carousel._page >= (this.carousel.totalDots() - 1);
if (!this.carousel?.page) {
return;
}

var end = this.carousel.page >= (this.carousel.totalDots() - 2) || this.carousel.totalDots() === 1;
if (end) {
var moviePromise: Promise<void>;
var tvPromise: Promise<void>;
Expand All @@ -178,7 +182,7 @@ export class CarouselListComponent implements OnInit {
}
}

private async loadData() {
private async loadData(clearExisting: boolean = true) {
var moviePromise: Promise<void>;
var tvPromise: Promise<void>;
switch (+this.discoverOptions) {
Expand All @@ -195,7 +199,7 @@ export class CarouselListComponent implements OnInit {
}
await moviePromise;
await tvPromise;
this.createInitialModel();
this.createInitialModel(clearExisting);
}

private async switchDiscoverMode(newMode: DiscoverOption) {
Expand Down Expand Up @@ -250,8 +254,10 @@ export class CarouselListComponent implements OnInit {
this.currentlyLoaded += this.amountToLoad;
}

private createInitialModel() {
this.clear();
private createInitialModel(clearExisting: boolean = true) {
if (clearExisting) {
this.clear();
}
this.createModel();
}

Expand Down

0 comments on commit fc69158

Please sign in to comment.