From f0f81e8db3ea4fb5dc2da453b2973e8bf06df01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 29 Aug 2018 13:23:22 +0200 Subject: [FIX] mail: correctly handle (non-)passive thread windows Definition of '(non-)passive' thread window: Thread windows can be either 'passive' or 'active' (default: 'active'). - When opening a thread window in 'active' mode, the messages are marked as read, and the focus is on the thread window. - When opening a thread window in 'passive' mode, the messages are not marked as read and there is no focus on the thread window. Messages are kept unread until the user interacts with the thread window (e.g. by clicking on composer). When the user intentionally opens a thread window, it should be open in active mode. However, when a thread window is open without any user iteractions, it should open in passive mode. The later case is useful in some cases. For instance, when receiving a new message from a DM conversation, it should automatically open the corresponding thread window. However, it should not automatically mark messages as read. This commit contains 2 bug fixes: 1. When receiving a new message on an active thread window, it no longer increments the unread counter. (When the focus is on the composer of the thread window, the user is immediately reading newly received messages.) 2. When receiving a new message from an unpinned DM conversation, the newly open thread window is always passive. (This was not the case before, so when receiving new messages, it did not increment the unread counter.) --- addons/mail/static/src/js/thread_windows/thread_window.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/mail/static/src/js/thread_windows/thread_window.js') diff --git a/addons/mail/static/src/js/thread_windows/thread_window.js b/addons/mail/static/src/js/thread_windows/thread_window.js index 20c0965205e..86cb3419eb9 100644 --- a/addons/mail/static/src/js/thread_windows/thread_window.js +++ b/addons/mail/static/src/js/thread_windows/thread_window.js @@ -164,11 +164,11 @@ var ThreadWindow = AbstractThreadWindow.extend({ * should scroll to the bottom if it was at the bottom before update * @param {boolean} [options.passively=false] if set, this thread window * becomes passive, so that it is marked as read only when the focus is - * on it. + * on it. Ignore this option if the focus is already on the thread window. */ update: function (options) { var self = this; - if (options.passively) { + if (options.passively && !this._hasFocus()) { this._setPassive(); } var bottomVisible = !this.isFolded() && -- cgit v1.2.3