From c44f35f61d3f93f0e4cfe3422ef0629a8b6e534b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 22 Mar 2022 15:05:22 +0000 Subject: [PATCH] [IMP] mail: turn 'MessageAuthorPrefixView/message' into field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-2793280 closes odoo/odoo#86980 Signed-off-by: Alexandre Kühn (aku) --- .../message_author_prefix.js | 8 -------- .../message_author_prefix.xml | 8 ++++---- .../thread_needaction_preview.xml | 1 - .../thread_preview/thread_preview.xml | 1 - .../src/models/message_author_prefix_view.js | 19 +++++++++++++++++++ 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js b/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js index d2224431136..ed2252b46db 100644 --- a/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js +++ b/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js @@ -13,13 +13,6 @@ export class MessageAuthorPrefix extends Component { return this.messaging && this.messaging.models['MessageAuthorPrefixView'].get(this.props.localId); } - /** - * @returns {Message} - */ - get message() { - return this.messaging && this.messaging.models['Message'].get(this.props.messageLocalId); - } - /** * @returns {Thread|undefined} */ @@ -32,7 +25,6 @@ export class MessageAuthorPrefix extends Component { Object.assign(MessageAuthorPrefix, { props: { localId: String, - messageLocalId: String, threadLocalId: { type: String, optional: true, diff --git a/addons/mail/static/src/components/message_author_prefix/message_author_prefix.xml b/addons/mail/static/src/components/message_author_prefix/message_author_prefix.xml index f39f62a4019..c1c6de7c187 100644 --- a/addons/mail/static/src/components/message_author_prefix/message_author_prefix.xml +++ b/addons/mail/static/src/components/message_author_prefix/message_author_prefix.xml @@ -4,12 +4,12 @@ - - + + You: - - : + + : diff --git a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml index e11baa8d3c4..3079011839f 100644 --- a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml +++ b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml @@ -42,7 +42,6 @@ diff --git a/addons/mail/static/src/components/thread_preview/thread_preview.xml b/addons/mail/static/src/components/thread_preview/thread_preview.xml index 697dcca769c..08dc75a63e8 100644 --- a/addons/mail/static/src/components/thread_preview/thread_preview.xml +++ b/addons/mail/static/src/components/thread_preview/thread_preview.xml @@ -48,7 +48,6 @@ diff --git a/addons/mail/static/src/models/message_author_prefix_view.js b/addons/mail/static/src/models/message_author_prefix_view.js index 0ec17d2b074..b1883d8db2c 100644 --- a/addons/mail/static/src/models/message_author_prefix_view.js +++ b/addons/mail/static/src/models/message_author_prefix_view.js @@ -2,11 +2,30 @@ import { registerModel } from '@mail/model/model_core'; import { one } from '@mail/model/model_field'; +import { clear, replace } from '@mail/model/model_field_command'; registerModel({ name: 'MessageAuthorPrefixView', identifyingFields: [['threadNeedactionPreviewViewOwner', 'threadPreviewViewOwner']], + recordMethods: { + /** + * @private + * @returns {FieldCommand} + */ + _computeMessage() { + if (this.threadNeedactionPreviewViewOwner) { + return replace(this.threadNeedactionPreviewViewOwner.thread.lastNeedactionMessageAsOriginThread); + } + if (this.threadPreviewViewOwner) { + return replace(this.threadPreviewViewOwner.thread.lastMessage); + } + return clear(); + }, + }, fields: { + message: one('Message', { + compute: '_computeMessage', + }), threadNeedactionPreviewViewOwner: one('ThreadNeedactionPreviewView', { inverse: 'messageAuthorPrefixView', readonly: true,