[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)
This commit is contained in:
Jérome Maes
2015-10-01 12:41:26 +02:00
parent 3304b31938
commit ea4dc68087
@@ -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(){