Move logic for notifying when reuqest is complete

pull/2467/head
Kenton Royal 6 years ago
parent 26904d3947
commit 4cad24f8e9

@ -2,6 +2,7 @@
import { RequestService } from "../services";
import { Component, Input, OnInit } from "@angular/core";
import { Observable } from "rxjs";
@Component({
selector: "remaining-requests",
@ -14,6 +15,7 @@ export class RemainingRequestsComponent implements OnInit {
public daysUntil: number;
public hoursUntil: number;
public minutesUntil: number;
@Input() quotaRefreshEvents: Observable<void>;
constructor(private requestService: RequestService) {
}
@ -23,7 +25,7 @@ export class RemainingRequestsComponent implements OnInit {
this.update();
this.requestService.requestEvents.subscribe(() => {
this.quotaRefreshEvents.subscribe(() => {
this.update();
});

@ -20,7 +20,7 @@
</div>
</div>
<remaining-requests [movie]="true" #remainingFilms></remaining-requests>
<remaining-requests [movie]="true" [quotaRefreshEvents]="movieRequested.asObservable()" #remainingFilms></remaining-requests>
<!-- Movie content -->
<div id="movieList">

@ -17,6 +17,7 @@ export class MovieSearchComponent implements OnInit {
public searchText: string;
public searchChanged: Subject<string> = new Subject<string>();
public movieRequested: Subject<void> = new Subject<void>();
public movieResults: ISearchMovieResult[];
public result: IRequestEngineResult;
@ -88,7 +89,7 @@ export class MovieSearchComponent implements OnInit {
try {
this.requestService.requestMovie({ theMovieDbId: searchResult.id })
.subscribe(x => {
this.requestService.requestEvents.next();
this.movieRequested.next();
this.result = x;
if (this.result.result) {
this.translate.get("Search.RequestAdded", { title: searchResult.title }).subscribe(x => {

@ -7,6 +7,7 @@ import { SearchService } from "../services";
import { INewSeasonRequests, IRequestEngineResult, ISeasonsViewModel, ITvRequestViewModel } from "../interfaces";
import { IEpisodesRequests } from "../interfaces";
import { ISearchTvResult } from "../interfaces";
import { Subject } from "rxjs";
@Component({
selector: "seriesinformation",
@ -18,9 +19,10 @@ export class SeriesInformationComponent implements OnInit {
public result: IRequestEngineResult;
public series: ISearchTvResult;
public requestedEpisodes: IEpisodesRequests[] = [];
@Input() private seriesId: number;
@Input() public tvRequested: Subject<void>;
constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService) { }
public ngOnInit() {
@ -62,7 +64,7 @@ export class SeriesInformationComponent implements OnInit {
this.requestService.requestTv(viewModel)
.subscribe(x => {
this.requestService.requestEvents.next();
this.tvRequested.next();
this.result = x as IRequestEngineResult;
if (this.result.result) {
this.notificationService.success(

@ -27,7 +27,7 @@
</div>
</div>
<remaining-requests [movie]="false" #remainingTvShows></remaining-requests>
<remaining-requests [movie]="false" [quotaRefreshEvents]="tvRequested.asObservable()" #remainingTvShows></remaining-requests>
<!-- Movie content -->
<div id="actorMovieList">
@ -153,7 +153,7 @@
</div>
<!--This is the section that holds the child seasons if they want to specify specific episodes-->
<div *ngIf="node.open">
<seriesinformation [seriesId]="node.id"></seriesinformation>
<seriesinformation [seriesId]="node.id" [tvRequested]="tvRequested"></seriesinformation>
</div>
<br/>

@ -18,6 +18,7 @@ export class TvSearchComponent implements OnInit {
public searchText: string;
public searchChanged = new Subject<string>();
public tvResults: ISearchTvResult[];
public tvRequested: Subject<void> = new Subject<void>();
public result: IRequestEngineResult;
public searchApplied = false;
public defaultPoster: string;
@ -161,7 +162,7 @@ export class TvSearchComponent implements OnInit {
this.requestService.requestTv(viewModel)
.subscribe(x => {
this.requestService.requestEvents.next();
this.tvRequested.next();
this.result = x;
if (this.result.result) {
this.notificationService.success(

@ -2,7 +2,7 @@ import { PlatformLocation } from "@angular/common";
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable, ReplaySubject } from "rxjs";
import { Observable } from "rxjs";
import { TreeNode } from "primeng/primeng";
import { FilterType, IChildRequests, IFilter, IMovieRequestModel, IMovieRequests, IMovieUpdateModel, IRequestEngineResult, IRequestsViewModel, ITvRequests, ITvUpdateModel, OrderType } from "../interfaces";
@ -13,8 +13,6 @@ import { IRemainingRequests } from "../interfaces/IRemainingRequests";
@Injectable()
export class RequestService extends ServiceHelpers {
public readonly requestEvents = new ReplaySubject();
constructor(http: HttpClient, public platformLocation: PlatformLocation) {
super(http, "/api/v1/Request/", platformLocation);
}

Loading…
Cancel
Save