From 3457e037e9801a700982153746c4ef8ec35f8183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Thu, 23 Aug 2018 14:10:03 +0200 Subject: [FIX] mail: mark document thread preview as read Before this commit, it was not possible to mark a document thread preview as read from the messaging menu. This issue comes from the fact that document message previews are built from messages in the Inbox. The computation of the unread counter is correct for the preview, but not for the associated document thread object which has a counter of 0. Since it is only possible to mark as read when the counter is strictly greater than 0, the 'mark as read' did not have any impact. This commit fixes this issue by ensuring that the unread counter of a document thread matches the number of needaction messages it contains. Task-ID 1875668 --- addons/mail/static/src/js/models/threads/document_thread.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'addons/mail/static/src/js/models/threads/document_thread.js') diff --git a/addons/mail/static/src/js/models/threads/document_thread.js b/addons/mail/static/src/js/models/threads/document_thread.js index 283bcf3ca66..f90da991960 100644 --- a/addons/mail/static/src/js/models/threads/document_thread.js +++ b/addons/mail/static/src/js/models/threads/document_thread.js @@ -188,6 +188,10 @@ var DocumentThread = Thread.extend({ * Add this message to this document thread. * * This is ignored if the message is already linked to this document thread. + * Also, there is no fetch of unread message counter in a document thread, + * as this object is built from messages and/or thread field widget. The + * unread counter of a document thread is the sum of needaction messages + * linked to this document thread. * * @override * @private @@ -207,6 +211,10 @@ var DocumentThread = Thread.extend({ if (!_.contains(this._messageIDs, message.getID())) { this._messageIDs.push(message.getID()); } + // update unread counter + if (message.isNeedaction()) { + this._unreadCounter++; + } }, /** * Get most up to date messageIDs -- cgit v1.2.3