diff --git a/src/app/features/home/stores/home.state.ts b/src/app/features/home/stores/home.state.ts index bb9353e98efd51bad2b5b7e1a6c11fb6946d36ac..315b6497a29ca385080ba3dd29c5b219537478d0 100644 --- a/src/app/features/home/stores/home.state.ts +++ b/src/app/features/home/stores/home.state.ts @@ -46,6 +46,7 @@ import { ApiService, CollectionTyped, defaultResourceStateInitValue, + ErrorDto, HttpStatus, isNullOrUndefined, isWhiteString, @@ -291,22 +292,30 @@ export class HomeState { }); let pooling: boolean = true; + let pendingRequest: boolean = false; let firstTimeError: boolean = false; this.notificationService.showInformation(TRANSLATE("home.archive.browsing.download.notification.inPreparation"), true); return interval(500) .pipe( - takeWhile(() => pooling === true), + takeWhile(() => pooling === true && pendingRequest === false), startWith(0), - mergeMap(() => this.getDownloadStatus(ctx, action.dataFile.resId)), + mergeMap(() => { + pendingRequest = true; + return this.getDownloadStatus(ctx, action.dataFile.resId).pipe( + tap(() => pendingRequest = false), + ); + }), tap((res: string) => { if (res === StringUtil.stringEmpty) { this.prepareDownload(ctx, action.dataFile.resId); + return; } if (res === Order.StatusEnum.READY) { this.downloadFile(ctx, action.dataFile.resId); pooling = false; + return; } if (res === Order.StatusEnum.INERROR) { pooling = false; @@ -314,8 +323,14 @@ export class HomeState { ctx.dispatch(new DownloadFail()); firstTimeError = true; } + return; } - })); + }), + catchError(error => { + pooling = false; + throw error; + }) + ); } @@ -341,8 +356,7 @@ export class HomeState { headers, responseType: "text", }).pipe( - tap((res: string) => res), - catchError((e/*: ErrorDto*/) => { + catchError((e: ErrorDto) => { if (e.status === HttpStatus.INTERNAL_SERVER_ERROR) { return of(Order.StatusEnum.INERROR); } diff --git a/src/app/shared/enums/business/deposit-status.enum.ts b/src/app/shared/enums/business/deposit-status.enum.ts index 2df73c2cec5bc288bad6694b5aa3bc9a8dd458ab..15b79dab520996ea8ab5dad476c1592aa3d67d52 100644 --- a/src/app/shared/enums/business/deposit-status.enum.ts +++ b/src/app/shared/enums/business/deposit-status.enum.ts @@ -1,6 +1,4 @@ import {Deposit} from "@app/generated-api"; -import {StatusEnum} from "@app/generated-api/model/deposit.model"; -import {PackageStatusEnum} from "@shared/enums/business/package-status.enum"; import { KeyValue, TRANSLATE,