[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.
This commit is contained in:
@@ -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];
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -48,7 +48,7 @@ QUnit.module('Document Thread', {
|
||||
},
|
||||
records: [{
|
||||
id: 1,
|
||||
author_id: [1, 'Me'],
|
||||
author_id: [partnerID, 'Me'],
|
||||
body: '<p>Some Message on a document</p>',
|
||||
channel_ids: [],
|
||||
model: 'some.res.model',
|
||||
|
||||
Reference in New Issue
Block a user