diff --git a/addons/website_livechat/static/src/js/im_livechat.js b/addons/website_livechat/static/src/js/im_livechat.js index 6b64318732e..1527057b259 100644 --- a/addons/website_livechat/static/src/js/im_livechat.js +++ b/addons/website_livechat/static/src/js/im_livechat.js @@ -25,21 +25,17 @@ LivechatButton.include({ /** * @override - * Called when the visitor closes the livechat chatter - * (no matter the way : close, send feedback, ..) + * 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 */ - _closeChat: function () { - var self = this; + _onCloseChatWindow: function (ev) { + this._super(ev); var cookie = utils.get_cookie('im_livechat_session'); if (cookie) { var channel = JSON.parse(cookie); - var ready = session.rpc('/im_livechat/visitor_leave_session', {uuid: channel.uuid}); - ready.then(self._super()); - } - else { - this._super(); + session.rpc('/im_livechat/visitor_leave_session', {uuid: channel.uuid}); + utils.set_cookie('im_livechat_session', "", -1); // remove cookie } }, });