From 6ac4cd7d7b93ea74de5e153f68bfbf35d78edcce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Wed, 21 Feb 2024 19:10:52 +0100 Subject: [PATCH] [FIX] mail: cache access to newestPersistentNotEmptyOfAllMessage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store in variable in sort instead of accessing many times (less proxy get). closes odoo/odoo#155068 Signed-off-by: Alexandre Kühn (aku) --- .../static/src/core/common/store_service.js | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/addons/mail/static/src/core/common/store_service.js b/addons/mail/static/src/core/common/store_service.js index 311ca692b6b..c5e33887e0b 100644 --- a/addons/mail/static/src/core/common/store_service.js +++ b/addons/mail/static/src/core/common/store_service.js @@ -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; },