diff options
| author | Sébastien Theys <seb@odoo.com> | 2021-01-20 17:12:01 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2021-01-20 17:12:01 +0000 |
| commit | 0e9fb00f7863593fa63a3adf2593fb48dfb168b1 (patch) | |
| tree | 72e3add4dea96c5c7ee11eca0a44a237a32bf563 /addons/mail/static/src/bugfix/bugfix.js | |
| parent | 6532c6ba7acb2de53fc839d5a7c5d8b200716565 (diff) | |
[FIX] mail: more consistent async handling of scroll feature
task-2333535
task-2388676
closes odoo/odoo#64505
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/bugfix/bugfix.js')
| -rw-r--r-- | addons/mail/static/src/bugfix/bugfix.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/mail/static/src/bugfix/bugfix.js b/addons/mail/static/src/bugfix/bugfix.js index 1253e69da8e..162bf606db5 100644 --- a/addons/mail/static/src/bugfix/bugfix.js +++ b/addons/mail/static/src/bugfix/bugfix.js @@ -10,6 +10,44 @@ odoo.define('mail/static/src/bugfix/bugfix.js', function (require) { }); // Should be moved to its own file in master. +odoo.define('mail/static/src/component_hooks/use_rendered_values/use_rendered_values.js', function (require) { +'use strict'; + +const { Component } = owl; +const { onMounted, onPatched } = owl.hooks; + +/** + * This hooks provides support for accessing the values returned by the given + * selector at the time of the last render. The values will be updated after + * every mount/patch. + * + * @param {function} selector function that will be executed at the time of the + * render and of which the result will be stored for future reference. + * @returns {function} function to call to retrieve the last rendered values. + */ +function useRenderedValues(selector) { + const component = Component.current; + let renderedValues; + let patchedValues; + + const __render = component.__render.bind(component); + component.__render = function () { + renderedValues = selector(); + return __render(...arguments); + }; + onMounted(onUpdate); + onPatched(onUpdate); + function onUpdate() { + patchedValues = renderedValues; + } + return () => patchedValues; +} + +return useRenderedValues; + +}); + +// Should be moved to its own file in master. odoo.define('mail/static/src/component_hooks/use_update/use_update.js', function (require) { 'use strict'; |
