From 60fc564b3e66f07873cc91b5c7fcfa702b4eb6f6 Mon Sep 17 00:00:00 2001 From: Dhruv Patel Date: Mon, 26 Apr 2021 06:22:50 +0000 Subject: [PATCH] [FIX] im_livechat: notify operator on leave channel for sharable support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when we are using the sharable support page (url : "/im_livechat/support/"), There is no "visitor left" message sent to the operator when any visitor left the channel. Ideally, when any visitor left the channel from the website or the support page should notify the operator that "Visitor has left the conversation". With this commit, the operator will get notified every time when visitor left the conversation from anywhere. Task-2210040 closes odoo/odoo#87414 X-original-commit: 8c6affdb7a59436c6fdba1ad0a7c68a7273c0468 Signed-off-by: Alexandre Kühn (aku) Signed-off-by: Sébastien Theys (seb) --- .../static/src/legacy/public_livechat.js | 14 +++++++++++++ .../static/src/legacy/public_livechat.js | 21 ------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/addons/im_livechat/static/src/legacy/public_livechat.js b/addons/im_livechat/static/src/legacy/public_livechat.js index 71332b7be10..202fc02755c 100644 --- a/addons/im_livechat/static/src/legacy/public_livechat.js +++ b/addons/im_livechat/static/src/legacy/public_livechat.js @@ -421,6 +421,7 @@ var LivechatButton = Widget.extend({ } else { this._closeChat(); } + this._visitorLeaveSession(); }, /** * @private @@ -470,6 +471,19 @@ var LivechatButton = Widget.extend({ ev.stopPropagation(); this._chatWindow.renderHeader(); }, + /** + * @private + * Called when the visitor leaves the livechat chatter the first time (first click on X button) + * this will deactivate the mail_channel, notify operator that visitor has left the channel. + */ + _visitorLeaveSession: function () { + var cookie = utils.get_cookie('im_livechat_session'); + if (cookie) { + var channel = JSON.parse(cookie); + session.rpc('/im_livechat/visitor_leave_session', {uuid: channel.uuid}); + utils.set_cookie('im_livechat_session', "", -1); // remove cookie + } + }, }); /* diff --git a/addons/website_livechat/static/src/legacy/public_livechat.js b/addons/website_livechat/static/src/legacy/public_livechat.js index ad0e984d4fd..69c274af3ab 100644 --- a/addons/website_livechat/static/src/legacy/public_livechat.js +++ b/addons/website_livechat/static/src/legacy/public_livechat.js @@ -2,7 +2,6 @@ odoo.define('website_livechat.legacy.website_livechat.livechat_request', functio "use strict"; var utils = require('web.utils'); -var session = require('web.session'); var LivechatButton = require('im_livechat.legacy.im_livechat.im_livechat').LivechatButton; const config = require('web.config'); @@ -42,26 +41,6 @@ LivechatButton.include({ }); } }, - - //-------------------------------------------------------------------------- - // Handlers - //-------------------------------------------------------------------------- - - /** - * @override - * Called when the visitor closes the livechat chatter the first time (first click on X button) - * this will deactivate the mail_channel, clean the chat request if any - * and allow the operators to send the visitor a new chat request - */ - _onCloseChatWindow: function (ev) { - this._super(ev); - var cookie = utils.get_cookie('im_livechat_session'); - if (cookie) { - var channel = JSON.parse(cookie); - session.rpc('/im_livechat/visitor_leave_session', {uuid: channel.uuid}); - utils.set_cookie('im_livechat_session', "", -1); // remove cookie - } - }, }); return {