Change way remainingrequests component is notified

pull/2467/head
Kenton Royal 6 years ago
parent 93e9b4cd4c
commit e6f24eabb4

@ -23,7 +23,7 @@ export class RemainingRequestsComponent implements OnInit {
this.update();
this.requestService.onRequested().subscribe(m => {
this.requestService.requestEvents.subscribe(() => {
this.update();
});

@ -88,6 +88,7 @@ export class MovieSearchComponent implements OnInit {
try {
this.requestService.requestMovie({ theMovieDbId: searchResult.id })
.subscribe(x => {
this.requestService.requestEvents.next();
this.result = x;
if (this.result.result) {
this.translate.get("Search.RequestAdded", { title: searchResult.title }).subscribe(x => {

@ -62,6 +62,7 @@ export class SeriesInformationComponent implements OnInit {
this.requestService.requestTv(viewModel)
.subscribe(x => {
this.requestService.requestEvents.next();
this.result = x as IRequestEngineResult;
if (this.result.result) {
this.notificationService.success(

@ -161,6 +161,7 @@ export class TvSearchComponent implements OnInit {
this.requestService.requestTv(viewModel)
.subscribe(x => {
this.requestService.requestEvents.next();
this.result = x;
if (this.result.result) {
this.notificationService.success(

@ -13,15 +13,12 @@ import { IRemainingRequests } from "../interfaces/IRemainingRequests";
@Injectable()
export class RequestService extends ServiceHelpers {
private requestEvents = new ReplaySubject<IRequestEngineResult>();
public readonly requestEvents = new ReplaySubject();
constructor(http: HttpClient, public platformLocation: PlatformLocation) {
super(http, "/api/v1/Request/", platformLocation);
}
public onRequested(): Observable<IRequestEngineResult> {
return this.requestEvents.asObservable();
}
public getRemainingMovieRequests(): Observable<IRemainingRequests> {
return this.http.get<IRemainingRequests>(`${this.url}movie/remaining`, {headers: this.headers});
}
@ -31,14 +28,7 @@ export class RequestService extends ServiceHelpers {
}
public requestMovie(movie: IMovieRequestModel): Observable<IRequestEngineResult> {
const observer = Observable.create(observer => {
this.http.post<IRequestEngineResult>(`${this.url}Movie/`, JSON.stringify(movie), {headers: this.headers}).subscribe(m => {
observer.next(m);
this.requestEvents.next(m);
});
});
return observer;
return this.http.post<IRequestEngineResult>(`${this.url}Movie/`, JSON.stringify(movie), {headers: this.headers});
}
public getTotalMovies(): Observable<number> {
@ -50,14 +40,7 @@ export class RequestService extends ServiceHelpers {
}
public requestTv(tv: ITvRequestViewModel): Observable<IRequestEngineResult> {
const observer = Observable.create(observer => {
return this.http.post<IRequestEngineResult>(`${this.url}TV/`, JSON.stringify(tv), { headers: this.headers }).subscribe(m => {
observer.next(m);
this.requestEvents.next(m);
});
});
return observer;
return this.http.post<IRequestEngineResult>(`${this.url}TV/`, JSON.stringify(tv), { headers: this.headers });
}
public approveMovie(movie: IMovieUpdateModel): Observable<IRequestEngineResult> {

Loading…
Cancel
Save