From 923fb7aa05f0e9e0e67440073993ec36bb0f5f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 3 Sep 2019 10:55:30 +0000 Subject: [PATCH] [FIX] im_livechat: no duplicated messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, when using website livechat with multiple tabs, it may duplicate messages in the chat window. This happens due to registering messages twice: - once, from `/mail/chat_history` - second, from receiving notification from master tab, via local storage. This commit fixes the issue by not registering messages that have already been registered (i.e. unique ID). opw-2052960 closes odoo/odoo#36370 Signed-off-by: Alexandre Kühn (aku) --- addons/im_livechat/static/src/js/im_livechat.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js index 7de6629f24e..f357e987e57 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -232,7 +232,12 @@ var LivechatButton = Widget.extend({ is_note: data.is_note, customer_email_data: [] }; - + var hasAlreadyMessage = _.some(this.messages, function (message) { + return message.id === msg.id; + }); + if (hasAlreadyMessage) { + return; + } // Compute displayed author name or email msg.displayed_author = msg.author_id && msg.author_id[1] || this.options.default_username;