From fc691585976893f69b5c4806147afbd68bdaeb61 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 16 Sep 2021 08:25:27 +0100 Subject: [PATCH] fix(discover): :bug: Fixed up the discover lists, 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 --- .../carousel-list/carousel-list.component.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts b/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts index 3ab5bbe17..a00146ad5 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts @@ -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); } } @@ -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; var tvPromise: Promise; @@ -178,7 +182,7 @@ export class CarouselListComponent implements OnInit { } } - private async loadData() { + private async loadData(clearExisting: boolean = true) { var moviePromise: Promise; var tvPromise: Promise; switch (+this.discoverOptions) { @@ -195,7 +199,7 @@ export class CarouselListComponent implements OnInit { } await moviePromise; await tvPromise; - this.createInitialModel(); + this.createInitialModel(clearExisting); } private async switchDiscoverMode(newMode: DiscoverOption) { @@ -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(); }