@@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
22import { Component , Inject , NgZone , OnInit , PLATFORM_ID } from '@angular/core' ;
33import { ActivatedRoute , Router } from '@angular/router' ;
44import { BehaviorSubject , Observable } from 'rxjs' ;
5- import { finalize , map , switchMap , take , tap , find , startWith } from 'rxjs/operators' ;
5+ import { finalize , map , switchMap , take , tap , find , startWith , filter } from 'rxjs/operators' ;
66import { AuthService } from '../../core/auth/auth.service' ;
77import { DSONameService } from '../../core/breadcrumbs/dso-name.service' ;
88import { BitstreamDataService } from '../../core/data/bitstream-data.service' ;
@@ -80,6 +80,8 @@ export class ProcessDetailComponent implements OnInit {
8080
8181 isRefreshing$ : Observable < boolean > ;
8282
83+ isDeleting : boolean ;
84+
8385 /**
8486 * Reference to NgbModal
8587 */
@@ -113,6 +115,7 @@ export class ProcessDetailComponent implements OnInit {
113115 return [ data . process as RemoteData < Process > ] ;
114116 }
115117 } ) ,
118+ filter ( ( ) => ! this . isDeleting ) ,
116119 redirectOn4xx ( this . router , this . authService ) ,
117120 ) ;
118121
@@ -203,15 +206,17 @@ export class ProcessDetailComponent implements OnInit {
203206 * @param process
204207 */
205208 deleteProcess ( process : Process ) {
209+ this . isDeleting = true ;
206210 this . processService . delete ( process . processId ) . pipe (
207211 getFirstCompletedRemoteData ( )
208212 ) . subscribe ( ( rd ) => {
209213 if ( rd . hasSucceeded ) {
210214 this . notificationsService . success ( this . translateService . get ( 'process.detail.delete.success' ) ) ;
211215 this . closeModal ( ) ;
212- this . router . navigateByUrl ( getProcessListRoute ( ) ) ;
216+ void this . router . navigateByUrl ( getProcessListRoute ( ) ) ;
213217 } else {
214218 this . notificationsService . error ( this . translateService . get ( 'process.detail.delete.error' ) ) ;
219+ this . isDeleting = false ;
215220 }
216221 } ) ;
217222 }
0 commit comments