A platform for community discussion. Free, open, simple.
DEV: Bypass video thumbnail generation if events don't fire (#35182)
Penar Musarajec23b7315330
diff --git a/app/assets/javascripts/discourse/app/lib/composer-video-thumbnail-uppy.js b/app/assets/javascripts/discourse/app/lib/composer-video-thumbnail-uppy.jsindex f38ec96ab1c..8db074d3232 100644--- a/app/assets/javascripts/discourse/app/lib/composer-video-thumbnail-uppy.js+++ b/app/assets/javascripts/discourse/app/lib/composer-video-thumbnail-uppy.js@@ -56,7 +56,16 @@ export default class ComposerVideoThumbnailUppy {const eventName = this.capabilities.isIOS? "onloadedmetadata": "oncanplaythrough";++ const stalledEventsTimer = setTimeout(() => {+ // in some cases, no video events are hit (for example, when browser disables autoplay)+ // we need to give up in those cases, otherwise the upload will hang+ return callback();+ }, 3000);+video[eventName] = () => {+ clearTimeout(stalledEventsTimer);+const canvas = document.createElement("canvas");const ctx = canvas.getContext("2d");diff --git a/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js b/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.jsindex 4236b4393b8..1eb708c1a1d 100644--- a/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js+++ b/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js@@ -376,7 +376,7 @@ export default class UppyComposerUpload {file,upload.url,- // This callback is fired even if the thumbnail callnot be generated,+ // This callback is fired even if the thumbnail cannot be generated,// e.g. if video_thumbnails_enabled is false or if the file is not a video.() => {this.#removeInProgressUpload(file.id);