From b903eb531fe1469e40a32a8dfd5fa05c72f72b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Wed, 21 Feb 2024 18:45:18 +0100 Subject: [PATCH] [FIX] mail: cache the compute of message datetime Avoid doing this process every time the datetime is accessed. It looks like it is already cached with `_datetime`, but it's not efficient because there are still many proxy get access (which are costly). 3 proxy access before: getter itself, reading _datetime twice 1 proxy access after: the field itself Part-of: odoo/odoo#155068 --- addons/mail/static/src/core/common/message_model.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/mail/static/src/core/common/message_model.js b/addons/mail/static/src/core/common/message_model.js index db454e03221..854b17f860d 100644 --- a/addons/mail/static/src/core/common/message_model.js +++ b/addons/mail/static/src/core/common/message_model.js @@ -187,12 +187,11 @@ export class Message extends Record { return dateDay; } - get datetime() { - if (!this._datetime) { - this._datetime = toRaw(this.date ? deserializeDateTime(this.date) : this.now); - } - return this._datetime; - } + datetime = Record.attr(undefined, { + compute() { + return toRaw(this.date ? deserializeDateTime(this.date) : this.now); + }, + }); get scheduledDate() { return toRaw(