From a203e5318efd1175d040f54105b68ad1df0222d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 16 Jul 2019 10:32:33 +0000 Subject: [PATCH] [FIX] mail: re-render discuss on message_fetch with typing members When (un)registering a typing members of a channel, the discuss sidebar must be re-render. This is necessary in order to display the typing indicator next to discuss items, i.e. '...'. When receiving a message from a typing member, this person no longer becomes a typing member. Before this commit, for each new messages, the discuss sidebar was re-rendered. This happens due to unregistering the author from the typing members of the channel, even when the author was not a typing member in the first place. With this commit, when the list of typing members of a channel does not change, the discuss sidebar won't re-render and slow down the whole UI. opw-2035443 closes odoo/odoo#33616 Signed-off-by: Martin Geubelle (mge) --- .../js/models/threads/mixins/thread_typing_mixin.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js b/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js index f995b4e09b3..d000bc4a7c5 100644 --- a/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js +++ b/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js @@ -171,11 +171,15 @@ var ThreadTypingMixin = { if (this._isTypingMyselfInfo(params)) { return; } + var partnerID = params.partnerID; this._othersTypingTimers.registerTimer({ - timeoutCallbackArguments: [params.partnerID], - timerID: params.partnerID, + timeoutCallbackArguments: [partnerID], + timerID: partnerID, }); - this._typingPartnerIDs.push(params.partnerID); + if (_.contains(this._typingPartnerIDs, partnerID)) { + return; + } + this._typingPartnerIDs.push(partnerID); this._warnUpdatedTypingPartners(); }, /** @@ -209,6 +213,9 @@ var ThreadTypingMixin = { unregisterTyping: function (params) { var partnerID = params.partnerID; this._othersTypingTimers.unregisterTimer({ timerID: partnerID }); + if (!_.contains(this._typingPartnerIDs, partnerID)) { + return; + } this._typingPartnerIDs = _.reject(this._typingPartnerIDs, function (id) { return id === partnerID; });