From 86fd7ab4f0a4eabf4ff6f8b9dd00b5733e4f0253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 24 Feb 2020 09:46:09 +0000 Subject: [PATCH] [FIX] mail: improve discuss new channel handling in mobile Revision on https://github.com/odoo/odoo/commit/8e5b6ab02aa95c204ea7bd241e6b8944d5972d43 Intent of commit above was to remove server-side synchronization of chat windows in mobile. To do so, it prevented sending RPCs for chat window state in mobile, in addition to not automatically adapt state of chat windows in mobile from longpolling notification. This implementation, while functionally working as intended, had disturbing intermediate logic that could potentially lead to bugs in the future. Specifically, on mobile, new channel did not directly trigger a re-render of discuss widgets. However, and thankfully, the related new message was triggering the rendering, so that UI correctly has channel and its notification. This commit simply improves code so that new channel always triggers a rendering, even in mobile, like before the commit above. Of course, to preserve the intent of not synchronizing chat windows in mobile, new detached channels must still not auto-open a chat window, and this commit clarifies this intended behaviour in the code. X-original-commit: 1046d063ca46aacb1e186599b5d4a02ef9c8e18d --- addons/mail/static/src/js/services/mail_manager.js | 10 ---------- .../static/src/js/services/mail_window_manager.js | 12 +++++++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/addons/mail/static/src/js/services/mail_manager.js b/addons/mail/static/src/js/services/mail_manager.js index 64e733abf43..6a2fe69581d 100644 --- a/addons/mail/static/src/js/services/mail_manager.js +++ b/addons/mail/static/src/js/services/mail_manager.js @@ -903,11 +903,6 @@ var MailManager = AbstractService.extend({ args: [[channelID]], }) .then(function (result) { - // Prevent to automatically open chat window when a new message - // is received on mobile. - if (config.device.isMobile) { - options.silent = true; - } return self._addChannel(result, options); }); }, @@ -1235,11 +1230,6 @@ var MailManager = AbstractService.extend({ var proms = []; const options = {}; - // Prevent to automatically open all chat windows at initial loading. - if (config.device.isMobile) { - options.silent = true; - } - _.each(data.channel_slots, function (channels) { _.each(channels, function (channel) { proms.push(self._addChannel(channel, options)); 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 57b7623e05a..9cbb77e529d 100644 --- a/addons/mail/static/src/js/services/mail_window_manager.js +++ b/addons/mail/static/src/js/services/mail_window_manager.js @@ -658,11 +658,13 @@ MailManager.include({ */ _onNewChannel: function (channel, proms) { if (channel.isDetached()) { - var prom = this.openThreadWindow(channel.getID(), { - keepFoldState: true, - passively: true, - }); - proms.push(prom); + if (!config.device.isMobile) { + var prom = this.openThreadWindow(channel.getID(), { + keepFoldState: true, + passively: true, + }); + proms.push(prom); + } } else { this._closeThreadWindow(channel.getID()); }