diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index 57489e822aa..a79734a92ef 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -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 diff --git a/addons/im_livechat/static/src/legacy/public_livechat.js b/addons/im_livechat/static/src/legacy/public_livechat.js index 4dab13c1139..bd9daa6ab5d 100644 --- a/addons/im_livechat/static/src/legacy/public_livechat.js +++ b/addons/im_livechat/static/src/legacy/public_livechat.js @@ -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