summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-07-31 14:42:35 +0000
committerDavid Beguin <dbe@odoo.com>2019-08-19 06:33:37 +0000
commita8ce2886be2e02315fa3526257a941c91c5385b9 (patch)
treeabd2c76b1affdf0cb3cb48899f8164281d63f097
parent498d2a80801b43619f8d3f343abf721de319137a (diff)
[FIX] im_livechat : avoid to send twice first operator message to visitor
What was going on here is that when the operator start the discussion with the visitor and the visitor navigates to a new page, the livechat button widget checks the cookie and see there is already a active conversation. It loads the mail_channel and write all the history of the conversation. So the first message is writting a first time. Then, it handles the notifications. As the visitor did not receive the first message notification yet, the first message notification comes up and the widget handle it. Adding the message a second time. To avoid this, we just stop the notification handling if the message is already present in the conversation. Task ID: 2028059 PR #34624
-rw-r--r--addons/im_livechat/static/src/js/im_livechat.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js
index 44c7dad0f05..596357ef3d4 100644
--- a/addons/im_livechat/static/src/js/im_livechat.js
+++ b/addons/im_livechat/static/src/js/im_livechat.js
@@ -178,6 +178,11 @@ var LivechatButton = Widget.extend({
this._livechat.unregisterTyping({ partnerID: partnerID });
}
} else { // normal message
+ // If message from notif is already in chatter messages, stop handling
+ if (this._messages.some(message => message.getID() === notification[1].id)) {
+ this._livechat.unregisterTyping({ partnerID: notification[1].author_id[0] });
+ return;
+ }
this._addMessage(notification[1]);
this._renderMessages();
if (this._chatWindow.isFolded() || !this._chatWindow.isAtBottom()) {