diff --git a/ui-ngx/src/app/core/interceptors/entity-conflict.interceptor.ts b/ui-ngx/src/app/core/interceptors/entity-conflict.interceptor.ts index c19f51f4ba..57ee28c779 100644 --- a/ui-ngx/src/app/core/interceptors/entity-conflict.interceptor.ts +++ b/ui-ngx/src/app/core/interceptors/entity-conflict.interceptor.ts @@ -31,7 +31,7 @@ import { } from '@shared/components/dialog/entity-conflict-dialog/entity-conflict-dialog.component'; import { HasId } from '@shared/models/base-data'; import { HasVersion } from '@shared/models/entity.models'; -import { InterceptorUtil } from './interceptor.util'; +import { getInterceptorConfig } from './interceptor.util'; @Injectable() export class EntityConflictInterceptor implements HttpInterceptor { @@ -61,8 +61,8 @@ export class EntityConflictInterceptor implements HttpInterceptor { next: HttpHandler, error: HttpErrorResponse ): Observable> { - if (InterceptorUtil.getConfig(request).ignoreVersionConflict) { - return next.handle(this.updateRequestVersion(request)); + if (getInterceptorConfig(request).ignoreVersionConflict) { + return throwError(() => error); } return this.openConflictDialog(request.body, error.error.message).pipe( diff --git a/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts b/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts index ab3a41f86e..1cdd0c506e 100644 --- a/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts +++ b/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts @@ -29,7 +29,7 @@ import { ActionNotificationShow } from '@app/core/notification/notification.acti import { DialogService } from '@core/services/dialog.service'; import { TranslateService } from '@ngx-translate/core'; import { parseHttpErrorMessage } from '@core/utils'; -import { InterceptorUtil } from './interceptor.util'; +import { getInterceptorConfig } from './interceptor.util'; const tmpHeaders = {}; @@ -50,7 +50,7 @@ export class GlobalHttpInterceptor implements HttpInterceptor { intercept(req: HttpRequest, next: HttpHandler): Observable> { if (req.url.startsWith('/api/')) { - const config = InterceptorUtil.getConfig(req); + const config = getInterceptorConfig(req); this.updateLoadingState(config, true); let observable$: Observable>; if (this.isTokenBasedAuthEntryPoint(req.url)) { @@ -94,7 +94,7 @@ export class GlobalHttpInterceptor implements HttpInterceptor { } private handleResponseError(req: HttpRequest, next: HttpHandler, errorResponse: HttpErrorResponse): Observable> { - const config = InterceptorUtil.getConfig(req); + const config = getInterceptorConfig(req); let unhandled = false; const ignoreErrors = config.ignoreErrors; const resendRequest = config.resendRequest; diff --git a/ui-ngx/src/app/core/interceptors/interceptor.util.ts b/ui-ngx/src/app/core/interceptors/interceptor.util.ts index 13352acf76..ed9fc41868 100644 --- a/ui-ngx/src/app/core/interceptors/interceptor.util.ts +++ b/ui-ngx/src/app/core/interceptors/interceptor.util.ts @@ -18,32 +18,29 @@ import { HttpRequest } from '@angular/common/http'; import { InterceptorConfig } from '@core/interceptors/interceptor-config'; import { InterceptorHttpParams } from '@core/interceptors/interceptor-http-params'; -export class InterceptorUtil { +const internalUrlPrefixes = [ + '/api/auth/token', + '/api/rpc' +]; - private static readonly internalUrlPrefixes = [ - '/api/auth/token', - '/api/rpc' - ]; - - static getConfig(req: HttpRequest): InterceptorConfig { - let config: InterceptorConfig; - if (req.params && req.params instanceof InterceptorHttpParams) { - config = (req.params as InterceptorHttpParams).interceptorConfig; - } else { - config = new InterceptorConfig(); - } - if (this.isInternalUrlPrefix(req.url)) { - config.ignoreLoading = true; - } - return config; +export const getInterceptorConfig = (req: HttpRequest): InterceptorConfig => { + let config: InterceptorConfig; + if (req.params && req.params instanceof InterceptorHttpParams) { + config = (req.params as InterceptorHttpParams).interceptorConfig; + } else { + config = new InterceptorConfig(); } - - private static isInternalUrlPrefix(url: string): boolean { - for (const prefix of this.internalUrlPrefixes) { - if (url.startsWith(prefix)) { - return true; - } - } - return false; + if (isInternalUrlPrefix(req.url)) { + config.ignoreLoading = true; } -} + return config; +}; + +const isInternalUrlPrefix = (url: string): boolean => { + for (const prefix of internalUrlPrefixes) { + if (url.startsWith(prefix)) { + return true; + } + } + return false; +};