From dea14bcd27c3b9f25e6f9dcbe4fb4f4a628b546b Mon Sep 17 00:00:00 2001 From: zel-odoo Date: Wed, 11 Oct 2023 13:23:19 +0200 Subject: [PATCH] [FIX] mail: no duplicate content on message of type email MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the duplicate message in the discuss and search when the message type is email. This was caused by a wrong rebase of https://github.com/odoo/odoo/pull/118794 that did not take into account the branching on message body for message of type email by https://github.com/odoo/odoo/pull/131202 The search highlight feature was not working on these email message, so this commit also fixes that. closes odoo/odoo#138205 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/core/common/message.js | 7 ++++++- addons/mail/static/src/core/common/message.xml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/core/common/message.js b/addons/mail/static/src/core/common/message.js index 656d38cd200..d16b1302178 100644 --- a/addons/mail/static/src/core/common/message.js +++ b/addons/mail/static/src/core/common/message.js @@ -52,6 +52,7 @@ import { cookie } from "@web/core/browser/cookie"; export class Message extends Component { // This is the darken version of #71639e static SHADOW_LINK_COLOR = "#66598f"; + static SHADOW_HIGHLIGHT_COLOR = "#e99d00bf"; static SHADOW_LINK_HOVER_COLOR = "#564b79"; static components = { ActionSwiper, @@ -155,7 +156,8 @@ export class Message extends Component { if (this.shadowBody.el) { this.shadowRoot = this.shadowBody.el.attachShadow({ mode: "open" }); const body = document.createElement("span"); - body.innerHTML = this.message.body; + body.innerHTML = + this.props.messageSearch?.highlight(this.message.body) ?? this.message.body; this.insertReadMoreLess($(body)); const color = cookie.get("color_scheme") === "dark" ? "white" : "black"; this.shadowStyle = document.createElement("style"); @@ -170,6 +172,9 @@ export class Message extends Component { a:hover, a *:hover { color: ${this.constructor.SHADOW_LINK_HOVER_COLOR} !important; } + .o-mail-Message-searchHighlight { + background: ${this.constructor.SHADOW_HIGHLIGHT_COLOR} !important; + } `; this.shadowRoot.appendChild(this.shadowStyle); this.shadowRoot.appendChild(body); diff --git a/addons/mail/static/src/core/common/message.xml b/addons/mail/static/src/core/common/message.xml index 6d3c03af0a3..0b78e640906 100644 --- a/addons/mail/static/src/core/common/message.xml +++ b/addons/mail/static/src/core/common/message.xml @@ -93,7 +93,7 @@