[IMP] im_livechat : set livechat inactive _onCloseChatWindow

If the visitor closes the livechat window, he is redirected on rating /
feedback / send_transcript screen but he cannot go back to the conversation,
except by reloading the whole page.

Conversation should then be considered as inactive after the first click on X.

This commit close the conversation (set as livechat inactive and send the
'has left conversation' message) at first time the visitor closes the
conversation.

Task ID: 2120210
PR #39939
This commit is contained in:
David Beguin
2020-02-12 16:06:22 +00:00
parent 20a7ae2657
commit 6f2865e456
@@ -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
}
},
});