summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/thread_icon/thread_icon.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2021-01-21 17:43:49 +0000
committerSébastien Theys <seb@odoo.com>2021-01-21 17:43:49 +0000
commit7f9af5747c7b650b6cf4ab894bdd0b113e77a78b (patch)
tree5152dca1d14355e7c7465b41fcbe9c80770e98a6 /addons/mail/static/src/components/thread_icon/thread_icon.js
parent47bfdf0592a5dd93870ca1a9da326351d70087bb (diff)
[FIX] mail, *: significantly reduce number of useless renders
* = hr_holidays, im_livechat, website_livechat A huge amount of components where rendered for no reason, notably when typing a new message (at every key press), which significantly slowed down the interface. There were 2 causes to this number of renders: - OWL rendering all children automatically, even if their props didn't change, unless `shouldUpdate` is overridden, which is now done. - `useStore` selectors being way too generous in what they observed task-2399731 closes odoo/odoo#62703 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/thread_icon/thread_icon.js')
-rw-r--r--addons/mail/static/src/components/thread_icon/thread_icon.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/addons/mail/static/src/components/thread_icon/thread_icon.js b/addons/mail/static/src/components/thread_icon/thread_icon.js
index 0b82d0c9510..71017ec0e55 100644
--- a/addons/mail/static/src/components/thread_icon/thread_icon.js
+++ b/addons/mail/static/src/components/thread_icon/thread_icon.js
@@ -4,6 +4,7 @@ odoo.define('mail/static/src/components/thread_icon/thread_icon.js', function (r
const components = {
ThreadTypingIcon: require('mail/static/src/components/thread_typing_icon/thread_typing_icon.js'),
};
+const useShouldUpdateBasedOnProps = require('mail/static/src/component_hooks/use_should_update_based_on_props/use_should_update_based_on_props.js');
const useStore = require('mail/static/src/component_hooks/use_store/use_store.js');
const { Component } = owl;
@@ -15,15 +16,24 @@ class ThreadIcon extends Component {
*/
constructor(...args) {
super(...args);
+ useShouldUpdateBasedOnProps();
useStore(props => {
const thread = this.env.models['mail.thread'].get(props.threadLocalId);
const correspondent = thread ? thread.correspondent : undefined;
return {
- correspondent: correspondent ? correspondent.__state : undefined,
- partnerRoot: this.env.messaging.partnerRoot
- ? this.env.messaging.partnerRoot.__state
- : undefined,
- thread: thread ? thread.__state : undefined,
+ correspondent,
+ correspondentImStatus: correspondent && correspondent.im_status,
+ history: this.env.messaging.history,
+ inbox: this.env.messaging.inbox,
+ moderation: this.env.messaging.moderation,
+ partnerRoot: this.env.messaging.partnerRoot,
+ starred: this.env.messaging.starred,
+ thread,
+ threadChannelType: thread && thread.channel_type,
+ threadModel: thread && thread.model,
+ threadOrderedOtherTypingMembersLength: thread && thread.orderedOtherTypingMembers.length,
+ threadPublic: thread && thread.public,
+ threadTypingStatusText: thread && thread.typingStatusText,
};
});
}