From 3f1ef1f11d72271b08eeff0330bd65d02caaa3f7 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 7 Dec 2015 15:21:43 +0100 Subject: [PATCH] [FIX] im_livechat: prevent starting multiple poll bus.poll() should be a private function, as it initializes a new longpolling. Only bus.start_polling() should be called as it prevents running multiple polls concurrently. On the website, bus.poll() was called each time the user clicked on the livechat button, blocking the whole UI if the user clicked 6 times in a row on that button, as only 6 RPCs can be done concurrently. A consequence of this fix is that the poll isn't restarted if the user opens a new livechat session just after closing one, so the messages sent through that session are delayed (~50 seconds). To circumvent this situation, we simply don't restore the livechat button after closing a livechat session (the button re-appears anyway at the next click, or after a refresh). --- addons/im_livechat/static/src/js/im_livechat.js | 3 +-- 1 file changed, 1 insertion(+), 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 1344172fc5d..7e592dce57a 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -84,7 +84,7 @@ var LivechatButton = Widget.extend({ self.render_messages(); bus.add_channel(channel.uuid); - bus.poll(); + bus.start_polling(); utils.set_cookie('im_livechat_session', JSON.stringify(channel), 60*60); } @@ -119,7 +119,6 @@ var LivechatButton = Widget.extend({ close_chat: function () { this.chat_window.destroy(); - this.$el.show(); utils.set_cookie('im_livechat_session', "", -1); // remove cookie },