[FIX] im_livechat: visitor sees typing notification of operator
task-2359991 closes odoo/odoo#60553 X-original-commit: 4ff9ff09193390d9b39b15046855f94a98ad8409 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com> Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -230,6 +230,7 @@ class ImLivechatChannel(models.Model):
|
||||
info['server_url'] = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
if info['available']:
|
||||
info['options'] = self._get_channel_infos()
|
||||
info['options']['current_partner_id'] = self.env.user.partner_id.id
|
||||
info['options']["default_username"] = username
|
||||
return info
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ var LivechatButton = Widget.extend({
|
||||
'close_chat_window': '_onCloseChatWindow',
|
||||
'post_message_chat_window': '_onPostMessageChatWindow',
|
||||
'save_chat_window': '_onSaveChatWindow',
|
||||
'updated_typing_partners': '_onUpdatedTypingPartners',
|
||||
'updated_unread_counter': '_onUpdatedUnreadCounter',
|
||||
},
|
||||
events: {
|
||||
@@ -187,6 +188,17 @@ var LivechatButton = Widget.extend({
|
||||
channel_uuid: this._livechat.getUUID(),
|
||||
page_history: history,
|
||||
});
|
||||
} else if (notificationData.info === 'typing_status') {
|
||||
const partnerID = notificationData.partner_id;
|
||||
if (partnerID === this.options.current_partner_id) {
|
||||
// ignore typing display of current partner.
|
||||
return;
|
||||
}
|
||||
if (notificationData.is_typing) {
|
||||
this._livechat.registerTyping({ partnerID });
|
||||
} else {
|
||||
this._livechat.unregisterTyping({ partnerID });
|
||||
}
|
||||
} else if ('body' in notificationData) { // normal message
|
||||
// If message from notif is already in chatter messages, stop handling
|
||||
if (this._messages.some(message => message.getID() === notificationData.id)) {
|
||||
@@ -430,6 +442,14 @@ var LivechatButton = Widget.extend({
|
||||
ev.stopPropagation();
|
||||
utils.set_cookie('im_livechat_session', utils.unaccent(JSON.stringify(this._livechat.toData())), 60 * 60);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
*/
|
||||
_onUpdatedTypingPartners(ev) {
|
||||
ev.stopPropagation();
|
||||
this._chatWindow.renderHeader();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
|
||||
Reference in New Issue
Block a user