diff options
| author | Alexandre Kühn <aku@odoo.com> | 2019-05-23 11:00:53 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2019-07-16 13:13:22 +0000 |
| commit | 4bde721f925bfe3d1e867565490d3830da150dcc (patch) | |
| tree | 33e646049c5c6b6cb201e87ad196d132c319c407 /addons/mail/static/src | |
| parent | cf8e74a1a7d3404f57798573e8b15ce4dc5b9be4 (diff) | |
[FIX] mail: notify other tabs on document thread message post
Before this commit, most new messages added to the mail manager were
handled as if recently posted from a document thread. As a result, it
was frequently setting a new item in the local storage to notify
other tabs from these new messages.
The intent of this behaviour is to notify other tabs of newly posted
messages in a document thread, without using a longpolling
notification. That means this logic should only apply on messages
that have been recently posted on a document thread.
Sometimes, this issue was breaking the local storage on Firefox.
It showed the error message "Quota Exceeded Error" whenever `setItem`
was used, even when items were removed beforehand. The capacity of
the storage was only a few Kbs on this domain, far from reaching the
maximum capacity. We think that this error comes from the concurrent
`setItem` on multiple tabs, but this is very hard to reproduce.
This commit fixes the issue by limiting the `setItem` to the tab
that really posted the message. Tests have been adapted in order to
pass only with this fix.
Diffstat (limited to 'addons/mail/static/src')
| -rw-r--r-- | addons/mail/static/src/js/models/threads/document_thread.js | 4 | ||||
| -rw-r--r-- | addons/mail/static/src/js/services/mail_document_thread_manager.js | 17 |
2 files changed, 8 insertions, 13 deletions
diff --git a/addons/mail/static/src/js/models/threads/document_thread.js b/addons/mail/static/src/js/models/threads/document_thread.js index 6c15b39d25e..8e354a6e93c 100644 --- a/addons/mail/static/src/js/models/threads/document_thread.js +++ b/addons/mail/static/src/js/models/threads/document_thread.js @@ -329,7 +329,9 @@ var DocumentThread = Thread.extend({ .then(function (messages) { messages[0].model = resModel; messages[0].res_id = resID; - self.call('mail_service', 'addMessage', messages[0]); + self.call('mail_service', 'addMessage', messages[0], { + postedFromDocumentThread: true, + }); return messages[0]; }); }); diff --git a/addons/mail/static/src/js/services/mail_document_thread_manager.js b/addons/mail/static/src/js/services/mail_document_thread_manager.js index a98ae317c9d..000a1c15fa5 100644 --- a/addons/mail/static/src/js/services/mail_document_thread_manager.js +++ b/addons/mail/static/src/js/services/mail_document_thread_manager.js @@ -48,23 +48,16 @@ MailManager.include({ * * @override * @param {Object} data - * @param {Array} [data.author_id] [int, string] where int is server ID of - * the author, and string is the name of the author. * @param {integer} data.id server ID of the message - * @param {string} [data.model] the model name of the document that this - * message is related to. - * @param {integer} [data.res_id] the ID of the document that this message - * is related to. - * + * @param {Object} [options] + * @param {boolean} [options.postedFromDocumentThread=false] */ - addMessage: function (data) { + addMessage: function (data, options) { var message = this.getMessage(data.id); if ( !message && - data.res_id && - data.model && - data.author_id && - data.author_id[0] === session.partner_id + options && + options.postedFromDocumentThread ) { var key = this.DOCUMENT_THREAD_MESSAGE_KEY; this.call('local_storage', 'setItem', key, data); |
