diff options
| author | Sébastien Theys <seb@odoo.com> | 2021-01-21 17:43:49 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2021-01-21 17:43:49 +0000 |
| commit | 7f9af5747c7b650b6cf4ab894bdd0b113e77a78b (patch) | |
| tree | 5152dca1d14355e7c7465b41fcbe9c80770e98a6 /addons/mail/static/src/components/chat_window/chat_window.js | |
| parent | 47bfdf0592a5dd93870ca1a9da326351d70087bb (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/chat_window/chat_window.js')
| -rw-r--r-- | addons/mail/static/src/components/chat_window/chat_window.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/addons/mail/static/src/components/chat_window/chat_window.js b/addons/mail/static/src/components/chat_window/chat_window.js index 8ae13de6d92..7e31cd3b6d4 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.js +++ b/addons/mail/static/src/components/chat_window/chat_window.js @@ -6,6 +6,7 @@ const components = { ChatWindowHeader: require('mail/static/src/components/chat_window_header/chat_window_header.js'), ThreadView: require('mail/static/src/components/thread_view/thread_view.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 useUpdate = require('mail/static/src/component_hooks/use_update/use_update.js'); const { isEventHandled } = require('mail/static/src/utils/utils.js'); @@ -22,14 +23,24 @@ class ChatWindow extends Component { */ constructor(...args) { super(...args); + useShouldUpdateBasedOnProps(); useStore(props => { const chatWindow = this.env.models['mail.chat_window'].get(props.chatWindowLocalId); const thread = chatWindow ? chatWindow.thread : undefined; return { - chatWindow: chatWindow ? chatWindow.__state : undefined, + chatWindow, + chatWindowHasNewMessageForm: chatWindow && chatWindow.hasNewMessageForm, + chatWindowIsDoFocus: chatWindow && chatWindow.isDoFocus, + chatWindowIsFocused: chatWindow && chatWindow.isFocused, + chatWindowIsFolded: chatWindow && chatWindow.isFolded, + chatWindowThreadView: chatWindow && chatWindow.threadView, + chatWindowVisibleIndex: chatWindow && chatWindow.visibleIndex, + chatWindowVisibleOffset: chatWindow && chatWindow.visibleOffset, isDeviceMobile: this.env.messaging.device.isMobile, localeTextDirection: this.env.messaging.locale.textDirection, - thread: thread ? thread.__state : undefined, + thread, + threadMassMailing: thread && thread.mass_mailing, + threadModel: thread && thread.model, }; }); useUpdate({ func: () => this._update() }); |
