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/models | |
| 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/models')
| -rw-r--r-- | addons/mail/static/src/models/thread_view/thread_view.js | 17 | ||||
| -rw-r--r-- | addons/mail/static/src/models/thread_view/thread_viewer.js | 16 |
2 files changed, 16 insertions, 17 deletions
diff --git a/addons/mail/static/src/models/thread_view/thread_view.js b/addons/mail/static/src/models/thread_view/thread_view.js index 5c65e19c0f8..bf4560998bd 100644 --- a/addons/mail/static/src/models/thread_view/thread_view.js +++ b/addons/mail/static/src/models/thread_view/thread_view.js @@ -45,17 +45,8 @@ function factory(dependencies) { * @param {Object} hint */ markComponentHintProcessed(hint) { - let filterFun; - switch (hint.type) { - case 'message-received': - filterFun = h => h.type !== hint.type && h.message !== hint.data.message; - break; - default: - filterFun = h => h.type !== hint.type; - break; - } this.update({ - componentHintList: this.componentHintList.filter(filterFun), + componentHintList: this.componentHintList.filter(h => h !== hint), }); this.env.messagingBus.trigger('o-thread-view-hint-processed', { hint, @@ -143,6 +134,8 @@ function factory(dependencies) { * @private */ _onThreadCacheChanged() { + // clear obsolete hints + this.update({ componentHintList: clear() }); this.addComponentHint('change-of-thread-cache'); if (this.threadCache) { this.threadCache.update({ isCacheRefreshRequested: true }); @@ -236,7 +229,9 @@ function factory(dependencies) { * a new message. Detection of new message is done through the component * hint `message-received`. */ - hasAutoScrollOnMessageReceived: attr(), + hasAutoScrollOnMessageReceived: attr({ + default: true, + }), /** * Last message in the context of the currently displayed thread cache. */ diff --git a/addons/mail/static/src/models/thread_view/thread_viewer.js b/addons/mail/static/src/models/thread_view/thread_viewer.js index 1e48e4ad805..c78022d4a53 100644 --- a/addons/mail/static/src/models/thread_view/thread_viewer.js +++ b/addons/mail/static/src/models/thread_view/thread_viewer.js @@ -14,9 +14,11 @@ function factory(dependencies) { /** * @param {integer} scrollHeight + * @param {mail.thread_cache} threadCache */ - saveThreadCacheScrollHeightAsInitial(scrollHeight) { - if (!this.threadCache) { + saveThreadCacheScrollHeightAsInitial(scrollHeight, threadCache) { + threadCache = threadCache || this.threadCache; + if (!threadCache) { return; } if (this.chatter) { @@ -27,16 +29,18 @@ function factory(dependencies) { } this.update({ threadCacheInitialScrollHeights: Object.assign({}, this.threadCacheInitialScrollHeights, { - [this.threadCache.localId]: scrollHeight, + [threadCache.localId]: scrollHeight, }), }); } /** * @param {integer} scrollTop + * @param {mail.thread_cache} threadCache */ - saveThreadCacheScrollPositionsAsInitial(scrollTop) { - if (!this.threadCache) { + saveThreadCacheScrollPositionsAsInitial(scrollTop, threadCache) { + threadCache = threadCache || this.threadCache; + if (!threadCache) { return; } if (this.chatter) { @@ -47,7 +51,7 @@ function factory(dependencies) { } this.update({ threadCacheInitialScrollPositions: Object.assign({}, this.threadCacheInitialScrollPositions, { - [this.threadCache.localId]: scrollTop, + [threadCache.localId]: scrollTop, }), }); } |
