diff --git a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts index 85891f87e..2864bdc5f 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts @@ -18,8 +18,8 @@ import type { import { dictionaryActionsTranslations, manualRedactionActionsTranslations } from '@translations/annotation-actions-translations'; import { Roles } from '@users/roles'; import { NGXLogger } from 'ngx-logger'; -import { of } from 'rxjs'; -import { tap } from 'rxjs/operators'; +import { EMPTY, of, OperatorFunction, pipe } from 'rxjs'; +import { catchError, tap } from 'rxjs/operators'; function getResponseType(error: boolean, isConflict: boolean) { const isConflictError = isConflict ? 'conflictError' : 'error'; @@ -150,22 +150,22 @@ export class ManualRedactionService extends GenericService { } #showToast(action: ManualRedactionActions | DictionaryActions, isDictionary = false) { - return tap({ - next: () => this._toaster.success(getMessage(action, isDictionary), { positionClass: 'toast-file-preview' }), - error: (error: unknown) => { + return pipe( + catchError((error: unknown) => { const isConflict = (error as HttpErrorResponse).status === HttpStatusCode.Conflict; this._toaster.error(getMessage(action, isDictionary, true, isConflict), { error: error as HttpErrorResponse, positionClass: 'toast-file-preview', }); - }, - }); + return EMPTY; + }), + tap(() => this._toaster.success(getMessage(action, isDictionary), { positionClass: 'toast-file-preview' })), + ); } #showAddToDictionaryToast(body: List, dictionaryLabel?: string) { - return tap({ - next: () => this._toaster.success(getDictionaryMessage('add'), { positionClass: 'toast-file-preview' }), - error: (error: unknown) => { + return pipe( + catchError((error: unknown) => { const isConflict = (error as HttpErrorResponse).status === HttpStatusCode.Conflict; this._toaster.error(getDictionaryMessage('add', true, isConflict), { error: error as HttpErrorResponse, @@ -175,7 +175,9 @@ export class ManualRedactionService extends GenericService { }, positionClass: 'toast-file-preview', }); - }, - }); + return EMPTY; + }), + tap(() => this._toaster.success(getDictionaryMessage('add'), { positionClass: 'toast-file-preview' })), + ); } }