Commit 104d03443a9093ed538b1fe844e0eef1d03ac358

Authored by Igor Kulikov
1 parent 76da0a0d

Fix HTTP interceptor loading state handling

@@ -61,8 +61,7 @@ export class GlobalHttpInterceptor implements HttpInterceptor { @@ -61,8 +61,7 @@ export class GlobalHttpInterceptor implements HttpInterceptor {
61 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { 61 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
62 if (req.url.startsWith('/api/')) { 62 if (req.url.startsWith('/api/')) {
63 const config = this.getInterceptorConfig(req); 63 const config = this.getInterceptorConfig(req);
64 - const isLoading = !this.isInternalUrlPrefix(req.url);  
65 - this.updateLoadingState(config, isLoading); 64 + this.updateLoadingState(config, true);
66 if (this.isTokenBasedAuthEntryPoint(req.url)) { 65 if (this.isTokenBasedAuthEntryPoint(req.url)) {
67 if (!AuthService.getJwtToken() && !this.authService.refreshTokenPending()) { 66 if (!AuthService.getJwtToken() && !this.authService.refreshTokenPending()) {
68 return this.handleResponseError(req, next, new HttpErrorResponse({error: {message: 'Unauthorized!'}, status: 401})); 67 return this.handleResponseError(req, next, new HttpErrorResponse({error: {message: 'Unauthorized!'}, status: 401}));
@@ -258,11 +257,16 @@ export class GlobalHttpInterceptor implements HttpInterceptor { @@ -258,11 +257,16 @@ export class GlobalHttpInterceptor implements HttpInterceptor {
258 } 257 }
259 258
260 private getInterceptorConfig(req: HttpRequest<any>): InterceptorConfig { 259 private getInterceptorConfig(req: HttpRequest<any>): InterceptorConfig {
  260 + let config: InterceptorConfig;
261 if (req.params && req.params instanceof InterceptorHttpParams) { 261 if (req.params && req.params instanceof InterceptorHttpParams) {
262 - return (req.params as InterceptorHttpParams).interceptorConfig; 262 + config = (req.params as InterceptorHttpParams).interceptorConfig;
263 } else { 263 } else {
264 - return new InterceptorConfig(false, false); 264 + config = new InterceptorConfig(false, false);
265 } 265 }
  266 + if (this.isInternalUrlPrefix(req.url)) {
  267 + config.ignoreLoading = true;
  268 + }
  269 + return config;
266 } 270 }
267 271
268 private showError(error: string, timeout: number = 0) { 272 private showError(error: string, timeout: number = 0) {