diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-09-29 18:50:23 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-09-29 19:47:12 +0000 |
| commit | fb9b1c8a169840951925fa810f71e865a54e3a31 (patch) | |
| tree | 591c34b02dfdde95ebaf296db7abfee5614e22ea /addons/mail/static/src/models/messaging_notification_handler | |
| parent | b4783500db5b7c645859227e8be5cd55025b2882 (diff) | |
[FIX] mail: reintroduce auto scroll on receiving message
task-2336251
closes odoo/odoo#58867
X-original-commit: f732980b2e5e83bcf2fdc8d3ce756f256cacbd4f
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/messaging_notification_handler')
| -rw-r--r-- | addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js index ede9245602d..6eb06ee01af 100644 --- a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js +++ b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js @@ -207,6 +207,7 @@ function factory(dependencies) { } const message = this.env.models['mail.message'].insert(convertedData); + this._notifyThreadViewsMessageReceived(message); // If the message was already known: nothing else should be done, // except if it was pending moderation by the current partner, then @@ -299,7 +300,7 @@ function factory(dependencies) { // knowledge of the channel return; } - const lastMessage = this.env.models['mail.message'].insert({id: last_message_id}); + const lastMessage = this.env.models['mail.message'].insert({ id: last_message_id }); // restrict computation of seen indicator for "non-channel" channels // for performance reasons const shouldComputeSeenIndicators = channel.channel_type !== 'channel'; @@ -631,7 +632,7 @@ function factory(dependencies) { starredMailbox.update({ counter: starred ? starredMailbox.counter + 1 - : starredMailbox.counter -1, + : starredMailbox.counter - 1, }); } } @@ -648,11 +649,12 @@ function factory(dependencies) { const convertedData = this.env.models['mail.message'].convertData(data); const messageIds = this.env.models['mail.message'].all().map(message => message.id); const partnerRoot = this.env.messaging.partnerRoot; - this.env.models['mail.message'].create(Object.assign(convertedData, { + const message = this.env.models['mail.message'].create(Object.assign(convertedData, { author: [['link', partnerRoot]], id: (messageIds ? Math.max(...messageIds) : 0) + 0.01, isTransient: true, })); + this._notifyThreadViewsMessageReceived(message); } /** @@ -756,6 +758,21 @@ function factory(dependencies) { }); } + /** + * Notifies threadViews about the given message being just received. + * This can allow them adjust their scroll position if applicable. + * + * @private + * @param {mail.message} + */ + _notifyThreadViewsMessageReceived(message) { + for (const thread of message.threads) { + for (const threadView of thread.threadViews) { + threadView.addComponentHint('message-received', { message }); + } + } + } + } MessagingNotificationHandler.fields = { |
