summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/chat_window/chat_window.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src/models/chat_window/chat_window.js')
-rw-r--r--addons/mail/static/src/models/chat_window/chat_window.js40
1 files changed, 38 insertions, 2 deletions
diff --git a/addons/mail/static/src/models/chat_window/chat_window.js b/addons/mail/static/src/models/chat_window/chat_window.js
index ab1aa214750..a4db3e638de 100644
--- a/addons/mail/static/src/models/chat_window/chat_window.js
+++ b/addons/mail/static/src/models/chat_window/chat_window.js
@@ -47,7 +47,7 @@ function factory(dependencies) {
expand() {
if (this.thread) {
- this.thread.openExpanded();
+ this.thread.open({ expanded: true });
}
}
@@ -82,9 +82,23 @@ function factory(dependencies) {
}
/**
- * Assume that this chat window was hidden before-hand.
+ * Makes this chat window active, which consists of making it visible,
+ * unfolding it, and focusing it.
+ */
+ makeActive() {
+ this.makeVisible();
+ this.unfold();
+ this.focus();
+ }
+
+ /**
+ * Makes this chat window visible by swapping it with the last visible
+ * chat window, or do nothing if it is already visible.
*/
makeVisible() {
+ if (this.isVisible) {
+ return;
+ }
const lastVisible = this.manager.lastVisible;
this.manager.swap(this, lastVisible);
}
@@ -161,6 +175,17 @@ function factory(dependencies) {
/**
* @private
+ * @returns {boolean}
+ */
+ _computeIsVisible() {
+ if (!this.manager) {
+ return false;
+ }
+ return this.manager.allOrderedVisible.includes(this);
+ }
+
+ /**
+ * @private
* @returns {string}
*/
_computeName() {
@@ -316,6 +341,17 @@ function factory(dependencies) {
],
default: false,
}),
+ /**
+ * Whether this chat window is visible or not. Should be considered
+ * read-only. Setting this value manually will not make it visible.
+ * @see `makeVisible`
+ */
+ isVisible: attr({
+ compute: '_computeIsVisible',
+ dependencies: [
+ 'managerAllOrderedVisible',
+ ],
+ }),
manager: many2one('mail.chat_window_manager', {
inverse: 'chatWindows',
}),