From 104d03443a9093ed538b1fe844e0eef1d03ac358 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 31 Aug 2021 19:34:49 +0300 Subject: [PATCH] Fix HTTP interceptor loading state handling --- .../app/core/interceptors/global-http-interceptor.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 be18613587..8c462955a8 100644 --- a/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts +++ b/ui-ngx/src/app/core/interceptors/global-http-interceptor.ts @@ -61,8 +61,7 @@ export class GlobalHttpInterceptor implements HttpInterceptor { intercept(req: HttpRequest, next: HttpHandler): Observable> { if (req.url.startsWith('/api/')) { const config = this.getInterceptorConfig(req); - const isLoading = !this.isInternalUrlPrefix(req.url); - this.updateLoadingState(config, isLoading); + this.updateLoadingState(config, true); if (this.isTokenBasedAuthEntryPoint(req.url)) { if (!AuthService.getJwtToken() && !this.authService.refreshTokenPending()) { return this.handleResponseError(req, next, new HttpErrorResponse({error: {message: 'Unauthorized!'}, status: 401})); @@ -258,11 +257,16 @@ export class GlobalHttpInterceptor implements HttpInterceptor { } private getInterceptorConfig(req: HttpRequest): InterceptorConfig { + let config: InterceptorConfig; if (req.params && req.params instanceof InterceptorHttpParams) { - return (req.params as InterceptorHttpParams).interceptorConfig; + config = (req.params as InterceptorHttpParams).interceptorConfig; } else { - return new InterceptorConfig(false, false); + config = new InterceptorConfig(false, false); } + if (this.isInternalUrlPrefix(req.url)) { + config.ignoreLoading = true; + } + return config; } private showError(error: string, timeout: number = 0) {