Skip to content

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

FIX: cancels saving draft when composer is destroyed (#21260)

Joffrey JAFFEUX36db953bc6a8
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs
index effa6885436..8c6953fcfbb 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs
@@ -30,6 +30,7 @@
{{did-update this.didUpdateInReplyTo this.currentMessage.inReplyTo}}
{{did-insert this.setupAppEvents}}
{{will-destroy this.teardownAppEvents}}
+ {{will-destroy this.cancelPersistDraft}}
>
<div class="chat-composer__outer-container">
<div class="chat-composer__inner-container">
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js b/plugins/chat/assets/javascripts/discourse/components/chat-composer.js
index 5602ef8981f..86142c3bc4b 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.js
@@ -98,6 +98,11 @@ export default class ChatComposer extends Component {
this.persistDraft();
}
+ @action
+ cancelPersistDraft() {
+ cancel(this._persistHandler);
+ }
+
get currentMessage() {
return this.composer.message;
}