From 3b28d037806946e89919c54293a1b41d12348630 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 4 Apr 2023 01:29:27 +0200 Subject: [PATCH] DEV: Fix a use-after-destroy issue (#20948) --- .../discourse/app/components/composer-messages.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); } });