summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/composer_text_input
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/composer_text_input
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/composer_text_input')
-rw-r--r--addons/mail/static/src/components/composer_text_input/composer_text_input.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/addons/mail/static/src/components/composer_text_input/composer_text_input.js b/addons/mail/static/src/components/composer_text_input/composer_text_input.js
index 3fba8115254..25796afff9d 100644
--- a/addons/mail/static/src/components/composer_text_input/composer_text_input.js
+++ b/addons/mail/static/src/components/composer_text_input/composer_text_input.js
@@ -1,6 +1,7 @@
odoo.define('mail/static/src/components/composer_text_input/composer_text_input.js', function (require) {
'use strict';
+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');
@@ -12,9 +13,6 @@ const { markEventHandled } = require('mail/static/src/utils/utils.js');
const { Component } = owl;
const { useRef } = owl.hooks;
-/**
- * ComposerInput relies on a minimal HTML editor in order to support mentions.
- */
class ComposerTextInput extends Component {
/**
@@ -22,11 +20,24 @@ class ComposerTextInput extends Component {
*/
constructor(...args) {
super(...args);
+ useShouldUpdateBasedOnProps({
+ compareDepth: {
+ sendShortcuts: 1,
+ },
+ });
useStore(props => {
const composer = this.env.models['mail.composer'].get(props.composerLocalId);
+ const thread = composer && composer.thread;
return {
- composer: composer ? composer.__state : undefined,
+ composerHasFocus: composer && composer.hasFocus,
+ composerHasSuggestions: composer && composer.hasSuggestions,
+ composerIsLog: composer && composer.isLog,
+ composerTextInputContent: composer && composer.textInputContent,
+ composerTextInputCursorEnd: composer && composer.textInputCursorEnd,
+ composerTextInputCursorStart: composer && composer.textInputCursorStart,
+ composerTextInputSelectionDirection: composer && composer.textInputSelectionDirection,
isDeviceMobile: this.env.messaging.device.isMobile,
+ threadModel: thread && thread.model,
};
});
/**
@@ -186,6 +197,7 @@ class ComposerTextInput extends Component {
*/
_onFocusinTextarea() {
this.composer.focus();
+ this.trigger('o-focusin-composer');
}
/**