From 003ff45f7572cf73e8991db4d13904b189edaf37 Mon Sep 17 00:00:00 2001 From: imanie383 Date: Tue, 17 May 2022 22:15:31 +0000 Subject: [PATCH] [FIX] mail: new messages extra domain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A default MAX(id) was added in the extraDomain when there are no messages to create it. This validation already existed but was omitted in the refactoring - https://github.com/odoo/odoo/pull/57061 Current behavior before PR: If there are no messageIds, the method loadNewMessages returns id > null and this domain returns 0 records https://github.com/odoo/odoo/blob/7d992af9561c499ef1912453f3b697bad18e441f/addons/mail/static/src/models/thread_cache/thread_cache.js#L55 Desired behavior after PR is merged: Create the extraDomain with a default MAX(id) when there are no messages to create it and continue with the normal flow of loadMessages closes odoo/odoo#91701 X-original-commit: dad6595ab08ccacefa1373a3fc97a729907d7d32 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/models/thread_cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/models/thread_cache.js b/addons/mail/static/src/models/thread_cache.js index 4517c15eb09..0aaa201cb77 100644 --- a/addons/mail/static/src/models/thread_cache.js +++ b/addons/mail/static/src/models/thread_cache.js @@ -53,7 +53,7 @@ registerModel({ return; } const messageIds = this.fetchedMessages.map(message => message.id); - const fetchedMessages = this._loadMessages({ minId: Math.max(...messageIds) }); + const fetchedMessages = this._loadMessages({ minId: Math.max(...messageIds, 0) }); if (!fetchedMessages || fetchedMessages.length === 0) { return; }