diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel.component.ts index 645cbde11..6f1b3773f 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewEncapsulation, Input } from "@angular/core"; +import { Component, ViewEncapsulation, Input, OnInit } from "@angular/core"; import { ISearchTvResultV2 } from "../../../../interfaces/ISearchTvResultV2"; @Component({ @@ -7,6 +7,17 @@ import { ISearchTvResultV2 } from "../../../../interfaces/ISearchTvResultV2"; selector: "tv-information-panel", encapsulation: ViewEncapsulation.None }) -export class TvInformationPanelComponent { +export class TvInformationPanelComponent implements OnInit { @Input() public tv: ISearchTvResultV2; + + public seasonCount: number; + public totalEpisodes: number = 0; + public nextEpisode: any; + + public ngOnInit(): void { + this.tv.seasonRequests.forEach(season => { + this.totalEpisodes = this.totalEpisodes + season.episodes.length; + }); + this.seasonCount = this.tv.seasonRequests.length; + } } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts index aa5aad6ee..4f56ee4b2 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts @@ -1,5 +1,5 @@ import { Component, ViewEncapsulation } from "@angular/core"; -import { ImageService, SearchV2Service, RequestService, MessageService } from "../../../services"; +import { ImageService, SearchV2Service, MessageService } from "../../../services"; import { ActivatedRoute } from "@angular/router"; import { DomSanitizer } from "@angular/platform-browser"; import { ISearchTvResultV2 } from "../../../interfaces/ISearchTvResultV2"; @@ -16,10 +16,6 @@ export class TvDetailsComponent { public tv: ISearchTvResultV2; public fromSearch: boolean; - public seasonCount: number; - public totalEpisodes: number = 0; - public nextEpisode: any; - private tvdbId: number; constructor(private searchService: SearchV2Service, private route: ActivatedRoute, @@ -41,12 +37,7 @@ export class TvDetailsComponent { this.tv = await this.searchService.getTvInfo(this.tvdbId); } - this.tv.seasonRequests.forEach(season => { - this.totalEpisodes = this.totalEpisodes + season.episodes.length; - }); - this.seasonCount = this.tv.seasonRequests.length; - - const tvBanner = await this.imageService.getTvBanner(this.tvdbId).toPromise(); + const tvBanner = await this.imageService.getTvBanner(this.tvdbId).toPromise(); this.tv.background = this.sanitizer.bypassSecurityTrustStyle("url(" + tvBanner + ")"); }