summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/thread/thread.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src/models/thread/thread.js')
-rw-r--r--addons/mail/static/src/models/thread/thread.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/addons/mail/static/src/models/thread/thread.js b/addons/mail/static/src/models/thread/thread.js
index a1818376233..bed46a7f41b 100644
--- a/addons/mail/static/src/models/thread/thread.js
+++ b/addons/mail/static/src/models/thread/thread.js
@@ -631,16 +631,22 @@ function factory(dependencies) {
* @param {boolean} [param0.expanded=false]
*/
async open({ expanded = false } = {}) {
+ const discuss = this.env.messaging.discuss;
// check if thread must be opened in form view
if (!['mail.box', 'mail.channel'].includes(this.model)) {
- return this.env.messaging.openDocument({
- id: this.id,
- model: this.model,
- });
+ if (expanded || discuss.isOpen) {
+ // Close chat window because having the same thread opened
+ // both in chat window and as main document does not look
+ // good.
+ this.env.messaging.chatWindowManager.closeThread(this);
+ return this.env.messaging.openDocument({
+ id: this.id,
+ model: this.model,
+ });
+ }
}
// check if thread must be opened in discuss
const device = this.env.messaging.device;
- const discuss = this.env.messaging.discuss;
if (
(!device.isMobile && (discuss.isOpen || expanded)) ||
this.model === 'mail.box'