Skip to content

A platform for community discussion. Free, open, simple.

FIX: Multiple video uploads in composer failed (#33216)

Martin Brennan21182883ef5c
diff --git a/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js b/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js
index b6d4ad205ca..2966bcd24e1 100644
--- a/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js
+++ b/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js
@@ -369,14 +369,17 @@ export default class UppyComposerUpload {
getUploadMarkdown(upload)
);
- // Only remove in progress after async resolvers finish:
- this.#removeInProgressUpload(file.id);
cacheShortUploadUrl(upload.short_url, upload);
new ComposerVideoThumbnailUppy(getOwner(this)).generateVideoThumbnail(
file,
upload.url,
+
+ // This callback is fired even if the thumbnail callnot be generated,
+ // e.g. if video_thumbnails_enabled is false or if the file is not a video.
() => {
+ this.#removeInProgressUpload(file.id);
+
this.placeholderHandler.success(file, markdown);
this.appEvents.trigger(
diff --git a/spec/system/composer_uploads_spec.rb b/spec/system/composer_uploads_spec.rb
index 6106fee0985..d5c036d2bf3 100644
--- a/spec/system/composer_uploads_spec.rb
+++ b/spec/system/composer_uploads_spec.rb
@@ -40,7 +40,7 @@ describe "Uploading files in the composer", type: :system do
context "when video thumbnails are enabled" do
before do
SiteSetting.video_thumbnails_enabled = true
- SiteSetting.authorized_extensions += "|webm"
+ SiteSetting.authorized_extensions += "|webm|mp4"
end
it "generates a topic preview thumbnail from the video" do
@@ -137,6 +137,19 @@ describe "Uploading files in the composer", type: :system do
expect(composer).to have_no_in_progress_uploads
expect(composer.preview).to have_css(".onebox-placeholder-container")
end
+
+ it "handles multiple video uploads" do
+ visit "/new-topic"
+ expect(composer).to be_opened
+ topic.fill_in_composer_title("Video upload test")
+
+ file_path_1 = file_from_fixtures("small.webm", "media").path
+ file_path_2 = file_from_fixtures("small.mp4", "media").path
+ attach_file([file_path_1, file_path_2]) { composer.click_toolbar_button("upload") }
+
+ expect(composer).to have_no_in_progress_uploads
+ expect(composer.preview).to have_css(".onebox-placeholder-container", count: 2)
+ end
end
context "when multiple images are uploaded" do