Skip to content

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

FIX: Disable the post submit button during image processing properly (#13765)

Rafael dos Santos Silva366238bb8114
diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js
index ae3addd81a9..ce73e3b597a 100644
--- a/app/assets/javascripts/discourse/app/components/composer-editor.js
+++ b/app/assets/javascripts/discourse/app/components/composer-editor.js
@@ -652,7 +652,6 @@ export default Component.extend({
this.setProperties({
uploadProgress: 0,
isUploading: false,
- isProcessingUpload: false,
isCancellable: false,
});
}
@@ -683,6 +682,14 @@ export default Component.extend({
});
$element
+ .on("fileuploadprocessstart", () => {
+ this.setProperties({
+ uploadProgress: 0,
+ isUploading: true,
+ isProcessingUpload: true,
+ isCancellable: false,
+ });
+ })
.on("fileuploadprocess", (e, data) => {
this.appEvents.trigger(
"composer:insert-text",
@@ -690,12 +697,6 @@ export default Component.extend({
filename: data.files[data.index].name,
})}]()\n`
);
- this.setProperties({
- uploadProgress: 0,
- isUploading: true,
- isProcessingUpload: true,
- isCancellable: false,
- });
})
.on("fileuploadprocessalways", (e, data) => {
this.appEvents.trigger(
@@ -705,6 +706,8 @@ export default Component.extend({
})}]()\n`,
""
);
+ })
+ .on("fileuploadprocessstop", () => {
this.setProperties({
uploadProgress: 0,
isUploading: false,
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 9443a74907d..e9fa6a2c80f 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -663,7 +663,7 @@ export default Controller.extend({
},
},
- disableSubmit: or("model.loading", "isUploading"),
+ disableSubmit: or("model.loading", "isUploading", "isProcessingUpload"),
save(force, options = {}) {
if (this.disableSubmit) {
diff --git a/app/assets/javascripts/discourse/app/templates/composer.hbs b/app/assets/javascripts/discourse/app/templates/composer.hbs
index 6cca5bcf1e1..b74974e784e 100644
--- a/app/assets/javascripts/discourse/app/templates/composer.hbs
+++ b/app/assets/javascripts/discourse/app/templates/composer.hbs
@@ -167,7 +167,7 @@
{{/if}}
{{/if}}
- {{#if isUploading}}
+ {{#if (or isUploading isProcessingUpload)}}
<div id="file-uploading">
{{#if isProcessingUpload}}
{{loading-spinner size="small"}}<span>{{i18n "upload_selector.processing"}}</span>