fix(request-list): 🐛 Fixed an issue where the bulk delete would not work for movie requests

This commit is contained in:
tidusjar 2021-11-22 12:14:31 +00:00
parent 332d9344d0
commit 4b540fb45b

View file

@ -1,7 +1,7 @@
import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, OnInit, Output, ViewChild } from "@angular/core"; import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, OnInit, Output, ViewChild } from "@angular/core";
import { IMovieRequests, IRequestEngineResult, IRequestsViewModel } from "../../../interfaces"; import { IMovieRequests, IRequestEngineResult, IRequestsViewModel } from "../../../interfaces";
import { NotificationService, RequestService } from "../../../services"; import { NotificationService, RequestService } from "../../../services";
import { Observable, forkJoin, merge, of as observableOf } from 'rxjs'; import { Observable, combineLatest, forkJoin, merge, of as observableOf } from 'rxjs';
import { catchError, map, startWith, switchMap } from 'rxjs/operators'; import { catchError, map, startWith, switchMap } from 'rxjs/operators';
import { AuthService } from "../../../auth/auth.service"; import { AuthService } from "../../../auth/auth.service";
@ -164,16 +164,16 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
if (this.selection.isEmpty()) { if (this.selection.isEmpty()) {
return; return;
} }
let tasks = new Array(); let tasks = new Array<Observable<IRequestEngineResult>>();
this.selection.selected.forEach((selected) => { this.selection.selected.forEach((selected) => {
tasks.push(this.requestServiceV1.removeMovieRequestAsync(selected.id)); tasks.push(this.requestServiceV1.removeMovieRequestAsync(selected.id));
}); });
await Promise.all(tasks); combineLatest(tasks).subscribe(() => {
this.notification.success(this.translateService.instant('Requests.RequestPanel.Deleted')) this.notification.success(this.translateService.instant('Requests.RequestPanel.Deleted'))
this.selection.clear(); this.selection.clear();
this.ngAfterViewInit(); this.ngAfterViewInit();
});
} }
public bulkApprove() { public bulkApprove() {