diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index fd6288098..10db95e76 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -244,6 +244,8 @@ namespace Ombi.Core.Engine public async Task RemoveTvChild(int requestId) { var request = await TvRepository.GetChild().FirstOrDefaultAsync(x => x.Id == requestId); + + TvRepository.Db.ChildRequests.Remove(request); var all = TvRepository.Db.TvRequests.Include(x => x.ChildRequests); var parent = all.FirstOrDefault(x => x.Id == request.ParentRequestId); @@ -255,7 +257,6 @@ namespace Ombi.Core.Engine } await Audit.Record(AuditType.Deleted, AuditArea.TvRequest, $"Deleting Request {request.Title}", Username); - TvRepository.Db.ChildRequests.Remove(request); await TvRepository.Db.SaveChangesAsync(); } diff --git a/src/Ombi.Core/Helpers/EmailValidator.cs b/src/Ombi.Core/Helpers/EmailValidator.cs index f310d5b08..af8d0dfd0 100644 --- a/src/Ombi.Core/Helpers/EmailValidator.cs +++ b/src/Ombi.Core/Helpers/EmailValidator.cs @@ -12,7 +12,7 @@ namespace Ombi.Core.Helpers { _invalid = false; if (string.IsNullOrEmpty(strIn)) - return false; + return true; // Use IdnMapping class to convert Unicode domain names. try diff --git a/src/Ombi/ClientApp/app/requests/tvrequest-children.component.ts b/src/Ombi/ClientApp/app/requests/tvrequest-children.component.ts index 798e63cc5..05ed2def1 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequest-children.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequest-children.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from "@angular/core"; +import { Component, EventEmitter, Input, Output } from "@angular/core"; import { IChildRequests } from "../interfaces"; import { NotificationService, RequestService } from "../services"; @@ -9,13 +9,18 @@ import { NotificationService, RequestService } from "../services"; export class TvRequestChildrenComponent { @Input() public childRequests: IChildRequests[]; @Input() public isAdmin: boolean; + + @Output() public requestDeleted = new EventEmitter(); + constructor(private requestService: RequestService, private notificationService: NotificationService) { } public removeRequest(request: IChildRequests) { this.requestService.deleteChild(request) - .subscribe(); - this.removeRequestFromUi(request); + .subscribe(x => { + this.removeRequestFromUi(request); + this.requestDeleted.emit(request.id); + }); } public changeAvailability(request: IChildRequests, available: boolean) { diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.html b/src/Ombi/ClientApp/app/requests/tvrequests.component.html index 22021fa28..aebd14bee 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.html @@ -58,7 +58,7 @@
- +
diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts index f46d1d86b..e34e998e4 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts @@ -101,6 +101,11 @@ export class TvRequestsComponent implements OnInit { this.showChildDialogue = true; } + public childRequestDeleted(childId: number): void { + // Refresh the UI, hackly way around reloading the data + this.ngOnInit(); + } + private loadInit() { this.requestService.getTvRequestsTree(this.amountToLoad, 0) .subscribe(x => { diff --git a/src/Ombi/ClientApp/app/services/request.service.ts b/src/Ombi/ClientApp/app/services/request.service.ts index 0d3167ea2..cbd3b0f71 100644 --- a/src/Ombi/ClientApp/app/services/request.service.ts +++ b/src/Ombi/ClientApp/app/services/request.service.ts @@ -91,7 +91,7 @@ export class RequestService extends ServiceAuthHelpers { public approveChild(child: ITvUpdateModel): Observable { return this.http.post(`${this.url}tv/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData); } - public deleteChild(child: IChildRequests): Observable { + public deleteChild(child: IChildRequests): Observable { return this.http.delete(`${this.url}tv/child/${child.id}`, { headers: this.headers }).map(this.extractData); } diff --git a/src/Ombi/ClientApp/app/services/service.helpers.ts b/src/Ombi/ClientApp/app/services/service.helpers.ts index 5101a3466..3738a2f0c 100644 --- a/src/Ombi/ClientApp/app/services/service.helpers.ts +++ b/src/Ombi/ClientApp/app/services/service.helpers.ts @@ -47,9 +47,12 @@ export class ServiceAuthHelpers { } protected extractData(res: Response) { - const body = res.json(); - //console.log('extractData', body || {}); - return body; + if(res.text()) { + const body = res.json(); + return body; + } else { + return ""; + } } protected handleError(error: any) {