Skip to content

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

DEV: refactor calls to message.cook when sending messages (#21934)

Andrei Prigorshnevc0d3cded7364
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.js b/plugins/chat/assets/javascripts/discourse/components/chat-channel.js
index f0fdb5827e2..bc0c1ee2742 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.js
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.js
@@ -647,6 +647,7 @@ export default class ChatLivePane extends Component {
@action
async onSendMessage(message) {
+ await message.cook();
if (message.editing) {
await this.#sendEditMessage(message);
} else {
@@ -660,7 +661,6 @@ export default class ChatLivePane extends Component {
}
async #sendEditMessage(message) {
- await message.cook();
this.pane.sending = true;
const data = {
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread.js b/plugins/chat/assets/javascripts/discourse/components/chat-thread.js
index 34710050030..330456960a5 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-thread.js
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread.js
@@ -228,6 +228,7 @@ export default class ChatThreadPanel extends Component {
async onSendMessage(message) {
resetIdle();
+ await message.cook();
if (message.editing) {
await this.#sendEditMessage(message);
} else {
@@ -281,7 +282,6 @@ export default class ChatThreadPanel extends Component {
}
async #sendEditMessage(message) {
- await message.cook();
this.chatThreadPane.sending = true;
const data = {
diff --git a/plugins/chat/assets/javascripts/discourse/models/chat-channel.js b/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
index b176140cfaa..19193446015 100644
--- a/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
+++ b/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
@@ -292,7 +292,6 @@ export default class ChatChannel {
message.draft = false;
message.createdAt ??= moment.utc().format();
message.channel = this;
- await message.cook();
if (message.inReplyTo) {
if (!this.threadingEnabled) {
diff --git a/plugins/chat/assets/javascripts/discourse/models/chat-thread.js b/plugins/chat/assets/javascripts/discourse/models/chat-thread.js
index 89ee3deee2f..ef6a0dfbae4 100644
--- a/plugins/chat/assets/javascripts/discourse/models/chat-thread.js
+++ b/plugins/chat/assets/javascripts/discourse/models/chat-thread.js
@@ -69,7 +69,6 @@ export default class ChatThread {
message.draft = false;
message.createdAt ??= moment.utc().format();
message.thread = this;
- await message.cook();
this.messagesManager.addMessages([message]);
}