[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
This commit is contained in:
David Beguin
2019-08-19 06:33:37 +00:00
parent 498d2a8080
commit a8ce2886be
@@ -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()) {