summaryrefslogtreecommitdiff
path: root/addons/im_livechat/static/src/bugfix/bugfix.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/im_livechat/static/src/bugfix/bugfix.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/im_livechat/static/src/bugfix/bugfix.js')
-rw-r--r--addons/im_livechat/static/src/bugfix/bugfix.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/addons/im_livechat/static/src/bugfix/bugfix.js b/addons/im_livechat/static/src/bugfix/bugfix.js
new file mode 100644
index 00000000..2a81f5e2
--- /dev/null
+++ b/addons/im_livechat/static/src/bugfix/bugfix.js
@@ -0,0 +1,34 @@
+/**
+ * This file allows introducing new JS modules without contaminating other files.
+ * This is useful when bug fixing requires adding such JS modules in stable
+ * versions of Odoo. Any module that is defined in this file should be isolated
+ * in its own file in master.
+ */
+odoo.define('im_livechat/static/src/bugfix/bugfix.js', function (require) {
+'use strict';
+
+const {
+ registerInstancePatchModel,
+} = require('mail/static/src/model/model_core.js');
+
+registerInstancePatchModel('mail.chat_window', 'im_livechat/static/src/models/chat_window/chat_window.js', {
+
+ /**
+ * @override
+ */
+ close({ notifyServer } = {}) {
+ if (
+ this.thread &&
+ this.thread.model === 'mail.channel' &&
+ this.thread.channel_type === 'livechat' &&
+ this.thread.mainCache.isLoaded &&
+ this.thread.messages.length === 0
+ ) {
+ notifyServer = true;
+ this.thread.unpin();
+ }
+ this._super({ notifyServer });
+ }
+});
+
+});