[FIX] mail: cache access to newestPersistentNotEmptyOfAllMessage

Store in variable in sort instead of accessing many times (less proxy
get).

closes odoo/odoo#155068

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2024-02-23 15:13:53 +00:00
parent 93078feeab
commit 6ac4cd7d7b
@@ -140,28 +140,16 @@ export class Store extends BaseStore {
if (bUnread > 0 && aUnread === 0) {
return 1;
}
if (
!a.newestPersistentNotEmptyOfAllMessage?.datetime &&
b.newestPersistentNotEmptyOfAllMessage?.datetime
) {
const aMessageDatetime = a.newestPersistentNotEmptyOfAllMessage?.datetime;
const bMessageDateTime = b.newestPersistentNotEmptyOfAllMessage?.datetime;
if (!aMessageDatetime && bMessageDateTime) {
return 1;
}
if (
!b.newestPersistentNotEmptyOfAllMessage?.datetime &&
a.newestPersistentNotEmptyOfAllMessage?.datetime
) {
if (!bMessageDateTime && aMessageDatetime) {
return -1;
}
if (
a.newestPersistentNotEmptyOfAllMessage?.datetime &&
b.newestPersistentNotEmptyOfAllMessage?.datetime &&
a.newestPersistentNotEmptyOfAllMessage?.datetime !==
b.newestPersistentNotEmptyOfAllMessage?.datetime
) {
return (
b.newestPersistentNotEmptyOfAllMessage.datetime -
a.newestPersistentNotEmptyOfAllMessage.datetime
);
if (aMessageDatetime && bMessageDateTime && aMessageDatetime !== bMessageDateTime) {
return bMessageDateTime - aMessageDatetime;
}
return b.localId > a.localId ? 1 : -1;
},