mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Added the ability for the discover options to stay/stick
This commit is contained in:
parent
2cba74e096
commit
e080afe05a
1 changed files with 17 additions and 9 deletions
|
@ -3,6 +3,7 @@ import { SearchV2Service } from "../../../services";
|
||||||
import { ISearchMovieResult, ISearchTvResult, RequestType } from "../../../interfaces";
|
import { ISearchMovieResult, ISearchTvResult, RequestType } from "../../../interfaces";
|
||||||
import { IDiscoverCardResult, DiscoverOption } from "../../interfaces";
|
import { IDiscoverCardResult, DiscoverOption } from "../../interfaces";
|
||||||
import { trigger, transition, style, animate } from "@angular/animations";
|
import { trigger, transition, style, animate } from "@angular/animations";
|
||||||
|
import { StorageService } from "../../../shared/storage/storage-service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./discover.component.html",
|
templateUrl: "./discover.component.html",
|
||||||
|
@ -21,13 +22,13 @@ export class DiscoverComponent implements OnInit {
|
||||||
public discoverResults: IDiscoverCardResult[] = [];
|
public discoverResults: IDiscoverCardResult[] = [];
|
||||||
public movies: ISearchMovieResult[] = [];
|
public movies: ISearchMovieResult[] = [];
|
||||||
public tvShows: ISearchTvResult[] = [];
|
public tvShows: ISearchTvResult[] = [];
|
||||||
|
|
||||||
public discoverOptions: DiscoverOption = DiscoverOption.Combined;
|
public discoverOptions: DiscoverOption = DiscoverOption.Combined;
|
||||||
public DiscoverOption = DiscoverOption;
|
public DiscoverOption = DiscoverOption;
|
||||||
|
|
||||||
public defaultTvPoster: string;
|
public defaultTvPoster: string;
|
||||||
|
|
||||||
public popularActive: boolean = true;
|
public popularActive: boolean;
|
||||||
public trendingActive: boolean;
|
public trendingActive: boolean;
|
||||||
public upcomingActive: boolean;
|
public upcomingActive: boolean;
|
||||||
|
|
||||||
|
@ -36,22 +37,28 @@ export class DiscoverComponent implements OnInit {
|
||||||
|
|
||||||
private contentLoaded: number;
|
private contentLoaded: number;
|
||||||
private isScrolling: boolean = false;
|
private isScrolling: boolean = false;
|
||||||
|
private mediaTypeStorageKey = "DiscoverOptions";
|
||||||
|
|
||||||
constructor(private searchService: SearchV2Service) { }
|
constructor(private searchService: SearchV2Service,
|
||||||
|
private storageService: StorageService) { }
|
||||||
|
|
||||||
public async ngOnInit() {
|
public async ngOnInit() {
|
||||||
this.loading()
|
this.loading()
|
||||||
|
const localDiscoverOptions = +this.storageService.get(this.mediaTypeStorageKey);
|
||||||
|
if (localDiscoverOptions) {
|
||||||
|
this.discoverOptions = DiscoverOption[DiscoverOption[localDiscoverOptions]];
|
||||||
|
}
|
||||||
this.scrollDisabled = true;
|
this.scrollDisabled = true;
|
||||||
switch (this.discoverOptions) {
|
switch (this.discoverOptions) {
|
||||||
case DiscoverOption.Combined:
|
case DiscoverOption.Combined:
|
||||||
this.movies = await this.searchService.popularMoviesByPage(0,12);
|
this.movies = await this.searchService.popularMoviesByPage(0, 12);
|
||||||
this.tvShows = await this.searchService.popularTvByPage(0,12);
|
this.tvShows = await this.searchService.popularTvByPage(0, 12);
|
||||||
break;
|
break;
|
||||||
case DiscoverOption.Movie:
|
case DiscoverOption.Movie:
|
||||||
this.movies = await this.searchService.popularMoviesByPage(0,12);
|
this.movies = await this.searchService.popularMoviesByPage(0, 12);
|
||||||
break;
|
break;
|
||||||
case DiscoverOption.Tv:
|
case DiscoverOption.Tv:
|
||||||
this.tvShows = await this.searchService.popularTvByPage(0,12);
|
this.tvShows = await this.searchService.popularTvByPage(0, 12);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +115,7 @@ export class DiscoverComponent implements OnInit {
|
||||||
case DiscoverOption.Tv:
|
case DiscoverOption.Tv:
|
||||||
this.tvShows = await this.searchService.anticipatedTvByPage(this.contentLoaded, 12);
|
this.tvShows = await this.searchService.anticipatedTvByPage(this.contentLoaded, 12);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.contentLoaded += 12;
|
this.contentLoaded += 12;
|
||||||
|
|
||||||
|
@ -199,7 +206,8 @@ export class DiscoverComponent implements OnInit {
|
||||||
public async switchDiscoverMode(newMode: DiscoverOption) {
|
public async switchDiscoverMode(newMode: DiscoverOption) {
|
||||||
this.loading();
|
this.loading();
|
||||||
this.clear();
|
this.clear();
|
||||||
this.discoverOptions = newMode;
|
this.discoverOptions = newMode;
|
||||||
|
this.storageService.save(this.mediaTypeStorageKey, newMode.toString());
|
||||||
await this.ngOnInit();
|
await this.ngOnInit();
|
||||||
this.finishLoading();
|
this.finishLoading();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue