diff options
| author | Aaron Bohy <aab@odoo.com> | 2015-12-04 11:00:18 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-12-07 16:32:27 +0100 |
| commit | 77acb57e55f0ea84cf021ccbb24c178b7f772673 (patch) | |
| tree | 987ab7f7e3904ab0086001e231fa6b754f01aa10 /addons | |
| parent | 030ba411a2522849323ef18b9bd9b38f87e38cbb (diff) | |
[FIX] mail: correctly increment channels' unread counter
When several channels followed the same document, and a message was sent in
this document, the unread counter of each channel was incremented by the number
of following channels (because as many notifications were sent on the bus, and
for each notification, we incremented the unread_counter of the channels in
which the corresponding message is posted).
This rev. makes sure to only increment the unread counter once, if the message
is not yet in the JS cache, i.e. if this is the first notification we receive
for this message.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/mail/static/src/js/chat_manager.js | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index b60f9a056c9..f780163689d 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -48,6 +48,9 @@ function add_message (data, options) { if (options.domain && options.domain !== []) { add_to_cache(msg, options.domain); } + if (options.increment_unread) { + update_channel_unread_counter(channel, channel.unread_counter+1); + } } if (channel && channel.hidden) { channel.hidden = false; @@ -380,13 +383,7 @@ function on_channel_notification (message) { def = $.when(); } def.then(function () { - _.each(message.channel_ids, function (channel_id) { - var channel = chat_manager.get_channel(channel_id); - if (channel) { - update_channel_unread_counter(channel, channel.unread_counter+1); - } - }); - add_message(message, { show_notification: true }); + add_message(message, { show_notification: true, increment_unread: true }); invalidate_caches(message.channel_ids); }); } |
