Skip to content

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

DEV: Fix a use-after-destroy issue (#20948)

Jarek Radosz3b28d0378069
diff --git a/app/assets/javascripts/discourse/app/components/composer-messages.js b/app/assets/javascripts/discourse/app/components/composer-messages.js
index 275d1c534c5..f400e139c5e 100644
--- a/app/assets/javascripts/discourse/app/components/composer-messages.js
+++ b/app/assets/javascripts/discourse/app/components/composer-messages.js
@@ -237,13 +237,17 @@ export default Component.extend({
this._similarTopicsMessage = message;
composer.store.find("similar-topic", { title, raw }).then((topics) => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
similarTopics.clear();
similarTopics.pushObjects(topics.get("content"));
if (similarTopics.get("length") > 0) {
message.set("similarTopics", similarTopics);
this.send("popup", message);
- } else if (message && !(this.isDestroyed || this.isDestroying)) {
+ } else if (message) {
this.send("hideMessage", message);
}
});