Skip to content

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

DEV: prevents uppy to act on destroyed object (#14224)

Joffrey JAFFEUX8bb331e63fc4
diff --git a/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js b/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
index 3636c058690..788a4416eec 100644
--- a/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
+++ b/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
@@ -147,6 +147,10 @@ export default Mixin.create({
});
this._uppyInstance.on("progress", (progress) => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
this.set("uploadProgress", progress);
});
diff --git a/app/assets/javascripts/discourse/app/mixins/upload.js b/app/assets/javascripts/discourse/app/mixins/upload.js
index 780b37536b8..ff7a73be570 100644
--- a/app/assets/javascripts/discourse/app/mixins/upload.js
+++ b/app/assets/javascripts/discourse/app/mixins/upload.js
@@ -103,6 +103,10 @@ export default Mixin.create({
});
$upload.on("fileuploadprogressall", (e, data) => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
const progress = parseInt((data.loaded / data.total) * 100, 10);
this.set("uploadProgress", progress);
});
diff --git a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js
index 101fce1ccc9..5c9cbb8aeb9 100644
--- a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js
+++ b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js
@@ -128,6 +128,10 @@ export default Mixin.create({
this._uppyInstance.use(UppyChecksum, { capabilities: this.capabilities });
this._uppyInstance.on("progress", (progress) => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
this.set("uploadProgress", progress);
});