diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-02-02 14:55:52 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-02-02 14:55:52 +0100 |
| commit | 04416a5a6f1a3b4cf1a8bed8e9aee9c30c91a03e (patch) | |
| tree | 1fd974be09d12c53ed02a221de553f6f83efc253 /addons/mail/static/src/js/chat_manager.js | |
| parent | 7e3d6e92b6a7af27d8c2ebb0dbbecba28c9f1877 (diff) | |
| parent | 469e04e97c2aa60d9d41bd430e0aeba77ee6f9dd (diff) | |
[MERGE] forward port of branch saas-9 up to 469e04e
Diffstat (limited to 'addons/mail/static/src/js/chat_manager.js')
| -rw-r--r-- | addons/mail/static/src/js/chat_manager.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 6fd85e33719..2db02429d7a 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -25,6 +25,7 @@ var channels = []; var channels_preview_def; var channel_defs = {}; var chat_unread_counter = 0; +var unread_conversation_counter = 0; var emojis = []; var emoji_substitutions = {}; var needaction_counter = 0; @@ -146,7 +147,7 @@ function add_message (data, options) { channel.hidden = false; chat_manager.bus.trigger('new_channel', channel); } - if (!msg.author_id || msg.author_id[0] !== session.partner_id) { + if (channel.type !== 'static' && !msg.is_author && !msg.is_system_notification) { if (options.increment_unread) { update_channel_unread_counter(channel, channel.unread_counter+1); } @@ -176,7 +177,9 @@ function make_message (data) { date: moment(time.str_to_datetime(data.date)), message_type: data.message_type, subtype_description: data.subtype_description, + is_author: data.author_id && data.author_id[0] === session.partner_id, is_note: data.is_note, + is_system_notification: data.message_type === 'notification' && data.model === 'mail.channel', attachment_ids: data.attachment_ids, subject: data.subject, email_from: data.email_from, @@ -240,11 +243,7 @@ function make_message (data) { } // Don't redirect on author clicked of self-posted messages - if (msg.author_id && msg.author_id[0] === session.partner_id) { - msg.author_redirect = false; - } else { - msg.author_redirect = true; - } + msg.author_redirect = !msg.is_author; // Compute the avatar_url if (msg.author_id && msg.author_id[0]) { @@ -449,8 +448,13 @@ function fetch_document_messages (ids, options) { } function update_channel_unread_counter (channel, counter) { + if (channel.unread_counter > 0 && counter === 0) { + unread_conversation_counter = Math.max(0, unread_conversation_counter-1); + } else if (channel.unread_counter === 0 && counter > 0) { + unread_conversation_counter++; + } if (channel.is_chat) { - chat_unread_counter = chat_unread_counter - channel.unread_counter + counter; + chat_unread_counter = Math.max(0, chat_unread_counter - channel.unread_counter + counter); } channel.unread_counter = counter; chat_manager.bus.trigger("update_channel_unread_counter", channel); @@ -807,6 +811,9 @@ var chat_manager = { get_chat_unread_counter: function () { return chat_unread_counter; }, + get_unread_conversation_counter: function () { + return unread_conversation_counter; + }, get_last_seen_message: function (channel) { if (channel.last_seen_message_id) { @@ -814,7 +821,7 @@ var chat_manager = { var msg = _.findWhere(messages, {id: channel.last_seen_message_id}); if (msg) { var i = _.sortedIndex(messages, msg, 'id') + 1; - while (i < messages.length && messages[i].author_id && messages[i].author_id[0] === session.partner_id) { + while (i < messages.length && (messages[i].is_author || messages[i].is_system_notification)) { msg = messages[i]; i++; } |
