From ea4dc6808787c0c5811a60e8ea4957d8a07dd029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Tue, 8 Sep 2015 11:49:36 +0200 Subject: [PATCH] [FIX] im_livechat : clean cookie managment Update the cookie after changing conversation state Deleting the conversation cookie when closing the conversation window Force open the conversation if a cookie is found (even if the state is closed) --- addons/im_livechat/static/src/js/im_livechat.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js index 49a02a6f155..7ff644f0e0a 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -38,6 +38,7 @@ mail_chat_common.Conversation.include({ // set manually the new state if(state === 'closed'){ this.destroy(); + utils.set_cookie('im_livechat_session', "", -1); }else{ if(state === 'open'){ this.show(); @@ -50,10 +51,10 @@ mail_chat_common.Conversation.include({ this.show(); } } + this._super(state); // session and cookie update utils.set_cookie('im_livechat_session', JSON.stringify(this.get('session')), 60*60); } - this._super(state); }, on_click_close: function(event) { var self = this; @@ -173,6 +174,11 @@ var LivechatButton = Widget.extend({ var self = this; // set the mail_channel and create the Conversation Window this.mail_channel = mail_channel; + // force open conversation window + if(mail_channel['state'] == 'closed'){ + mail_channel['state'] = 'open'; + } + this.conv = this.manager.session_apply(mail_channel, { 'load_history': !welcome_message, 'focus': welcome_message @@ -181,7 +187,6 @@ var LivechatButton = Widget.extend({ bus.bus.stop_polling(); delete self.conv; delete self.mail_channel; - utils.set_cookie('im_livechat_session', "", -1); // delete the session cookie }); // setup complet when the conversation window is appended this.manager._session_defs[mail_channel.id].then(function(){