From cf8fb9195e522e0b8b36fcc66459b599f51db413 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 25 Oct 2023 10:43:06 +0200 Subject: [PATCH] correctif(upload): ETQ usager, lorsque j'upload un fichier, ca bloque le bouton pour deposer un dossier --- .../controllers/autosave_controller.ts | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/app/javascript/controllers/autosave_controller.ts b/app/javascript/controllers/autosave_controller.ts index 0be1bf0cf..025010f8f 100644 --- a/app/javascript/controllers/autosave_controller.ts +++ b/app/javascript/controllers/autosave_controller.ts @@ -165,17 +165,25 @@ export class AutosaveController extends ApplicationController { private enqueueAutouploadRequest(target: HTMLInputElement, file: File) { const autoupload = new AutoUpload(target, file); - autoupload.start().catch((e) => { - const error = e as FileUploadError; - // Report unexpected client errors to Sentry. - // (But ignore usual client errors, or errors we can monitor better on the server side.) - if ( - error.failureReason == FAILURE_CLIENT && - error.code != ERROR_CODE_READ - ) { - throw error; - } - }); + autoupload + .start() + .catch((e) => { + const error = e as FileUploadError; + + this.globalDispatch('autosave:error'); + + // Report unexpected client errors to Sentry. + // (But ignore usual client errors, or errors we can monitor better on the server side.) + if ( + error.failureReason == FAILURE_CLIENT && + error.code != ERROR_CODE_READ + ) { + throw error; + } + }) + .then(() => { + this.globalDispatch('autosave:end'); + }); } // Add a new autosave request to the queue.