|
|
|
@ -135,10 +135,25 @@ export class CarouselListComponent implements OnInit {
|
|
|
|
|
this.discoverOptions = DiscoverOption[DiscoverOption[localDiscoverOptions]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(this.discoverResults.length < 14) {
|
|
|
|
|
let currentIteration = 0;
|
|
|
|
|
while (this.discoverResults.length <= 14 && currentIteration <= 3) {
|
|
|
|
|
currentIteration++;
|
|
|
|
|
await this.loadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async toggleChanged(event: MatButtonToggleChange) {
|
|
|
|
|
await this.switchDiscoverMode(event.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 (end) {
|
|
|
|
|
var moviePromise: Promise<void>;
|
|
|
|
|
var tvPromise: Promise<void>;
|
|
|
|
|
switch (this.discoverOptions) {
|
|
|
|
|
switch (+this.discoverOptions) {
|
|
|
|
|
case DiscoverOption.Combined:
|
|
|
|
|
moviePromise = this.loadMovies();
|
|
|
|
|
tvPromise = this.loadTv();
|
|
|
|
@ -150,26 +165,17 @@ export class CarouselListComponent implements OnInit {
|
|
|
|
|
tvPromise = this.loadTv();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await moviePromise;
|
|
|
|
|
await tvPromise;
|
|
|
|
|
|
|
|
|
|
this.createInitialModel();
|
|
|
|
|
}
|
|
|
|
|
this.createModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async toggleChanged(event: MatButtonToggleChange) {
|
|
|
|
|
await this.switchDiscoverMode(event.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 (end) {
|
|
|
|
|
private async loadData() {
|
|
|
|
|
var moviePromise: Promise<void>;
|
|
|
|
|
var tvPromise: Promise<void>;
|
|
|
|
|
switch (this.discoverOptions) {
|
|
|
|
|
switch (+this.discoverOptions) {
|
|
|
|
|
case DiscoverOption.Combined:
|
|
|
|
|
moviePromise = this.loadMovies();
|
|
|
|
|
tvPromise = this.loadTv();
|
|
|
|
@ -183,9 +189,7 @@ export class CarouselListComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
await moviePromise;
|
|
|
|
|
await tvPromise;
|
|
|
|
|
|
|
|
|
|
this.createModel();
|
|
|
|
|
}
|
|
|
|
|
this.createInitialModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async switchDiscoverMode(newMode: DiscoverOption) {
|
|
|
|
@ -193,9 +197,10 @@ export class CarouselListComponent implements OnInit {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.loading();
|
|
|
|
|
this.discoverOptions = newMode;
|
|
|
|
|
this.currentlyLoaded = 0;
|
|
|
|
|
this.discoverOptions = +newMode;
|
|
|
|
|
this.storageService.save(this.mediaTypeStorageKey, newMode.toString());
|
|
|
|
|
await this.ngOnInit();
|
|
|
|
|
await this.loadData();
|
|
|
|
|
this.finishLoading();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -237,7 +242,7 @@ export class CarouselListComponent implements OnInit {
|
|
|
|
|
private createModel() {
|
|
|
|
|
const tempResults = <IDiscoverCardResult[]>[];
|
|
|
|
|
|
|
|
|
|
switch (this.discoverOptions) {
|
|
|
|
|
switch (+this.discoverOptions) {
|
|
|
|
|
case DiscoverOption.Combined:
|
|
|
|
|
tempResults.push(...this.mapMovieModel());
|
|
|
|
|
tempResults.push(...this.mapTvModel());
|
|
|
|
|