@osovitny/anatoly 3.21.27 → 3.21.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2616,21 +2616,28 @@ class AnatolyHttpInterceptor {
2616
2616
  req = req.clone({ headers: req.headers.set('Accept', 'application/json') });
2617
2617
  req = req.clone({ headers: req.headers.set('Accept', 'application/text') });
2618
2618
  try {
2619
- this.onRequestStart(loadingRequired);
2620
2619
  let request$;
2620
+ let requestStarted = false;
2621
+ let handleRequest = () => {
2622
+ requestStarted = true;
2623
+ this.onRequestStart(loadingRequired);
2624
+ return this.handleHttpRequest(req, next);
2625
+ };
2621
2626
  if (authorizationTokenRequired) {
2622
2627
  request$ = this.authService.getAccessToken().pipe(mergeMap((token) => {
2623
2628
  if (token) {
2624
2629
  req = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + token) });
2625
2630
  }
2626
- return this.handleHttpRequest(req, next);
2631
+ return handleRequest();
2627
2632
  }));
2628
2633
  }
2629
2634
  else {
2630
- request$ = this.handleHttpRequest(req, next);
2635
+ request$ = handleRequest();
2631
2636
  }
2632
2637
  return request$.pipe(finalize(() => {
2633
- this.onRequestEnd(loadingRequired);
2638
+ if (requestStarted) {
2639
+ this.onRequestEnd(loadingRequired);
2640
+ }
2634
2641
  }));
2635
2642
  }
2636
2643
  catch (err) {