upload: Use Uppy's "onBeforeFileAdded" to allow duplicate file uploads.

Using `uppy.removeFile` is incompatible with where the upload-success
callback is moved to in @uppy/tus 4.1.4.
This commit is contained in:
Alex Vandiver
2024-12-17 21:56:29 +00:00
committed by Tim Abbott
parent 2d758951b4
commit 3f00d3d493

View File

@@ -139,7 +139,7 @@ export let hide_upload_banner = (
config.upload_banner(file_id).remove();
}
if (uppy.getFiles().length === 0) {
if (uppy.getFiles().every((e) => e.progress.uploadComplete)) {
if (config.mode === "compose") {
compose_validate.set_upload_in_progress(false);
} else {
@@ -286,6 +286,7 @@ export function setup_upload(config: Config): Uppy {
},
pluralize: (_n) => 0,
},
onBeforeFileAdded: () => true, // Allow duplicate file uploads
});
uppy.use(Tus, {
// https://uppy.io/docs/tus/#options
@@ -421,9 +422,6 @@ export function setup_upload(config: Config): Uppy {
compose_ui.autosize_textarea($text_area);
// The uploaded files should be removed since uppy doesn't allow files in the store
// to be re-uploaded again.
uppy.removeFile(file.id);
// Hide upload status after waiting 100ms after the 1s transition to 100%
// so that the user can see the progress bar at 100%.
hide_upload_banner(uppy, config, file.id, 1100);