Commit 04460be8 authored by Florent POITTEVIN's avatar Florent POITTEVIN
Browse files

fix: wait all upload finished before refresh list datafile

parent f5ff0b99
......@@ -613,10 +613,11 @@ export class DepositState extends ResourceLogoState<DepositStateModel, Deposit>
isLoadingCounter: ctx.getState().isLoadingCounter - 1,
});
this.notificationService.showSuccess(MARK_AS_TRANSLATABLE("deposit.file.upload.notification.success"));
ctx.dispatch(new DepositDataFileAction.Refresh(action.parentId));
const uploadFileStatusCopied = ObjectUtil.clone(action.uploadFileStatus);
DataFileUploadHelper.updateCompletedUploadFileStatus(ctx, uploadFileStatusCopied, action.depositDataFile);
this.checkPendingDownload(ctx);
if (!this.checkIsPendingDownload(ctx)) {
ctx.dispatch(new DepositDataFileAction.Refresh(action.parentId));
}
}
@Action(DepositAction.UploadDataFileFail)
......@@ -631,15 +632,16 @@ export class DepositState extends ResourceLogoState<DepositStateModel, Deposit>
this.notificationService.showError(errorMessage);
const uploadFileStatusCopied = ObjectUtil.clone(action.uploadFileStatus);
DataFileUploadHelper.updateErrorUploadFileStatus(ctx, uploadFileStatusCopied, errorMessage);
this.checkPendingDownload(ctx);
this.checkIsPendingDownload(ctx);
}
private checkPendingDownload(ctx: StateContext<DepositStateModel>): void {
if (ctx.getState()
.uploadStatus
.filter(u => u.status === FileUploadStatusEnum.inProgress || u.status === FileUploadStatusEnum.started).length === 0) {
private checkIsPendingDownload(ctx: StateContext<DepositStateModel>): boolean {
const isPendingDownload = ctx.getState().uploadStatus
.filter(u => u.status === FileUploadStatusEnum.inProgress || u.status === FileUploadStatusEnum.started).length > 0;
if (!isPendingDownload) {
ctx.dispatch(new AppAction.CancelPreventExit());
}
return isPendingDownload;
}
@Action(DepositAction.RetrySendDataFile)
......@@ -662,7 +664,7 @@ export class DepositState extends ResourceLogoState<DepositStateModel, Deposit>
cancelDataFileSending(ctx: StateContext<DepositStateModel>, action: DepositAction.MarkAsCancelDataFileSending): void {
DataFileUploadHelper.removeToUploadStatus(ctx, action.uploadFileStatus);
this.notificationService.showInformation(MARK_AS_TRANSLATABLE("deposit.file.upload.notification.info.canceled"));
this.checkPendingDownload(ctx);
this.checkIsPendingDownload(ctx);
}
@Action(DepositAction.ReserveDOI)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment