summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/message/message.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-11-16 12:36:47 +0000
committerSébastien Theys <seb@odoo.com>2020-11-16 12:36:47 +0000
commit2002c6a599a685f4a18fc670a9f7992c8d595c0f (patch)
treee4d273d6cd86496d68e9ebd02c3849d9f52d95d1 /addons/mail/static/src/models/message/message.js
parent8b32e558fde3cb3aaa1deb40acb07488d04d343e (diff)
[FIX] mail: fix race conditions, especially with scroll
The `_update` of some components must take place before the `_update` of other (usually sibling) components that might directly influence their layout. This is in particular the case for `_update` that are relying on height. Prevent force save of scroll position if there are pending hints to adjust it, and prevent pending hints from overriding new scroll value. Prevent flicker with message date. This should fix all known issues related to incorrectly saving or restoring scroll position. task-2344226 task-2358066 task-2369332 task-2372339 task-2373741 closes odoo/odoo#61054 Related: odoo/enterprise#14736 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/message/message.js')
-rw-r--r--addons/mail/static/src/models/message/message.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/addons/mail/static/src/models/message/message.js b/addons/mail/static/src/models/message/message.js
index 6ca7cf4a5bd..c3318aa8906 100644
--- a/addons/mail/static/src/models/message/message.js
+++ b/addons/mail/static/src/models/message/message.js
@@ -4,7 +4,8 @@ odoo.define('mail/static/src/models/message/message.js', function (require) {
const emojis = require('mail.emojis');
const { registerNewModel } = require('mail/static/src/model/model_core.js');
const { attr, many2many, many2one, one2many } = require('mail/static/src/model/model_field.js');
-const { addLink, htmlToTextContentInline, parseAndTransform } = require('mail.utils');
+const { clear } = require('mail/static/src/model/model_field_command.js');
+const { addLink, htmlToTextContentInline, parseAndTransform, timeFromNow } = require('mail.utils');
const { str_to_datetime } = require('web.time');
@@ -315,6 +316,13 @@ function factory(dependencies) {
}
/**
+ * Refreshes the value of `dateFromNow` field to the "current now".
+ */
+ refreshDateFromNow() {
+ this.update({ dateFromNow: this._computeDateFromNow() });
+ }
+
+ /**
* Action to initiate reply to current message in Discuss Inbox. Assumes
* that Discuss and Inbox are already opened.
*/
@@ -361,6 +369,16 @@ function factory(dependencies) {
}
/**
+ * @returns {string}
+ */
+ _computeDateFromNow() {
+ if (!this.date) {
+ return clear();
+ }
+ return timeFromNow(this.date);
+ }
+
+ /**
* @returns {boolean}
*/
_computeFailureNotifications() {
@@ -516,6 +534,15 @@ function factory(dependencies) {
date: attr({
default: moment(),
}),
+ /**
+ * States the time elapsed since date up to now.
+ */
+ dateFromNow: attr({
+ compute: '_computeDateFromNow',
+ dependencies: [
+ 'date',
+ ],
+ }),
email_from: attr(),
failureNotifications: one2many('mail.notification', {
compute: '_computeFailureNotifications',