diff --git a/addons/im_livechat/static/src/embed/common/message_patch.js b/addons/im_livechat/static/src/embed/common/message_patch.js index be08238adbe..604f2efcf92 100644 --- a/addons/im_livechat/static/src/embed/common/message_patch.js +++ b/addons/im_livechat/static/src/embed/common/message_patch.js @@ -4,6 +4,7 @@ import { Message } from "@mail/core/common/message"; import { patch } from "@web/core/utils/patch"; import { url } from "@web/core/utils/urls"; +import { SESSION_STATE } from "./livechat_service"; Message.props.push("isTypingMessage?"); @@ -17,6 +18,22 @@ patch(Message.prototype, { return this.props.thread?.type === "livechat" ? 2 : super.quickActionCount; }, + get canAddReaction() { + return ( + super.canAddReaction && + (this.props.thread?.type !== "livechat" || + this.env.services["im_livechat.livechat"].state === SESSION_STATE.PERSISTED) + ); + }, + + get canReplyTo() { + return ( + super.canReplyTo && + (this.props.thread?.type !== "livechat" || + this.env.services["im_livechat.chatbot"].inputEnabled) + ); + }, + /** * @param {import("@im_livechat/embed/common/chatbot/chatbot_step_model").StepAnswer} answer */ diff --git a/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js b/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js index ab41f3cc946..0c1c768f4c3 100644 --- a/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js +++ b/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js @@ -26,7 +26,17 @@ registry.category("web_tour.tours").add("website_livechat_chatbot_flow_tour", { }, { trigger: messagesContain("How can I help you?"), - run: () => {}, // check question_selection message is posted + // check question_selection message is posted and reactions are not + // available since the thread is not yet persisted + run() { + if ( + this.$anchor[0].querySelector( + ".o-mail-Message-actions [title='Add a Reaction']" + ) + ) { + console.error("Reactions should not be available before thread is persisted."); + } + }, }, { trigger: 'li:contains("I want to buy the software")', @@ -34,7 +44,17 @@ registry.category("web_tour.tours").add("website_livechat_chatbot_flow_tour", { }, { trigger: messagesContain("I want to buy the software"), - run: () => {}, // check selected option is posted + // check selected option is posted and reactions are available since + // the thread has been persisted in the process + run() { + if ( + !this.$anchor[0].querySelector( + ".o-mail-Message-actions [title='Add a Reaction']" + ) + ) { + console.error("Reactions should be available since thread is persisted."); + } + }, }, { trigger: messagesContain("Can you give us your email please?"),