diff --git a/src/app/dialogs/add-blinds/add-blinds.component.ts b/src/app/dialogs/add-blinds/add-blinds.component.ts index 6506bf3..7ab886f 100644 --- a/src/app/dialogs/add-blinds/add-blinds.component.ts +++ b/src/app/dialogs/add-blinds/add-blinds.component.ts @@ -130,45 +130,27 @@ export class AddBlindsComponent extends BaseAddDialogComponent this.fetchService.trigger()), - tap(() => { - if (this.dialogRef) { - this.dialogRef.close({ - blindId: model.blindIds - }); - } - - this.isLoadingAdd = false; - }), - catchError(() => { - this.isLoadingAdd = false; - return of(null); - }) - ).subscribe(); - } - - if (this.data.structure) { - this.blindStructureApiService.addBlinds$(model.blindIds, model.parentId, positions).pipe( - take(1), - tap((a) => this.fetchService.trigger()), - tap(() => { - if (this.dialogRef) { - this.dialogRef.close({ - blindId: model.blindIds - }); - } - - this.isLoadingAdd = false; - }), - catchError(() => { - this.isLoadingAdd = false; - return of(null); - }) - ).subscribe(); - } + const action$ = this.data.tournament + ? this.tournamentApiService.addBlinds$(model.blindIds, model.parentId, positions) + : this.blindStructureApiService.addBlinds$(model.blindIds, model.parentId, positions); + + action$.pipe( + take(1), + tap((a) => this.fetchService.trigger()), + tap(() => { + if (this.dialogRef) { + this.dialogRef.close({ + blindId: model.blindIds + }); + } + + this.isLoadingAdd = false; + }), + catchError(() => { + this.isLoadingAdd = false; + return of(null); + }) + ).subscribe(); } }