[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).
This commit is contained in:
@@ -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
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user