summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-08-29 13:23:22 +0200
committerAlexandre Kühn <aku@odoo.com>2018-08-30 13:30:12 +0200
commitf0f81e8db3ea4fb5dc2da453b2973e8bf06df01d (patch)
treec0cfb110e7d6892f0604ae43c4601ab64ce4a55a /addons/mail/static/src
parentbe44efe852e96840ff6db139ea66952cbad74e1a (diff)
[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.)
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/js/services/mail_window_manager.js2
-rw-r--r--addons/mail/static/src/js/thread_windows/abstract_thread_window.js10
-rw-r--r--addons/mail/static/src/js/thread_windows/thread_window.js4
3 files changed, 13 insertions, 3 deletions
diff --git a/addons/mail/static/src/js/services/mail_window_manager.js b/addons/mail/static/src/js/services/mail_window_manager.js
index de614ba705f..79ea668e55e 100644
--- a/addons/mail/static/src/js/services/mail_window_manager.js
+++ b/addons/mail/static/src/js/services/mail_window_manager.js
@@ -641,7 +641,7 @@ MailManager.include({
*/
_onNewChannel: function (channel) {
if (channel.isDetached()) {
- this.openThreadWindow(channel.getID(), { keepFoldState: true });
+ this.openThreadWindow(channel.getID(), { keepFoldState: true, passively: true });
} else {
this._closeThreadWindow(channel.getID());
}
diff --git a/addons/mail/static/src/js/thread_windows/abstract_thread_window.js b/addons/mail/static/src/js/thread_windows/abstract_thread_window.js
index 8a8bf3a0077..801a8166787 100644
--- a/addons/mail/static/src/js/thread_windows/abstract_thread_window.js
+++ b/addons/mail/static/src/js/thread_windows/abstract_thread_window.js
@@ -350,6 +350,16 @@ var AbstractThreadWindow = Widget.extend({
return this._thread.getID();
},
/**
+ * Tells whether there is focus on this thread. Note that a thread that has
+ * the focus means the input has focus.
+ *
+ * @private
+ * @returns {boolean}
+ */
+ _hasFocus: function () {
+ return this.$input.is(':focus');
+ },
+ /**
* Post a message on this thread window, and auto-scroll to the bottom of
* the thread.
*
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() &&