[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
This commit is contained in:
Sébastien Theys
2024-02-23 15:13:53 +00:00
parent a37b0171dd
commit b903eb531f
@@ -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(