diff options
| author | Aaron Bohy <aab@odoo.com> | 2015-11-13 14:28:18 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-11-16 09:51:08 +0100 |
| commit | 196e1322f208958634bf44d2cbff99295670e3cd (patch) | |
| tree | a84e26f63454e679dbbfdbfd4224266ce4ed7ae6 /addons/mail/static/src/js | |
| parent | 48942f1242acbdf6a74640104932adabfa9dcefe (diff) | |
[FIX] mail: needactions: mark as (un)read
Marking a message as read in the inbox doesn't remove needactions on all
channels anymore.
When joining a channel (other than the inbox) in which there are needactions,
those needactions are automatically marked as read and removed from the inbox.
When the user clicked on Undo in the snackbar, the messages weren't correctly
re-inserted in the inbox (in the JS cache).
Diffstat (limited to 'addons/mail/static/src/js')
| -rw-r--r-- | addons/mail/static/src/js/chat_manager.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 01cc6918264..e5913f4232b 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -378,14 +378,14 @@ function on_mark_as_read_notification (data) { chat_manager.bus.trigger('update_message', message); } }); - if (data.channel_ids.length) { + if (data.channel_ids) { _.each(data.channel_ids, function (channel_id) { var channel = chat_manager.get_channel(channel_id); if (channel) { channel.needaction_counter -= data.message_ids.length; } }); - } else { + } else { // if no channel_ids specified, this is a 'mark all read' in the inbox _.each(channels, function (channel) { channel.needaction_counter = 0; }); @@ -395,6 +395,12 @@ function on_mark_as_read_notification (data) { } function on_mark_as_unread_notification (data) { + _.each(data.message_ids, function (message_id) { + var message = _.findWhere(messages, { id: message_id }); + if (message) { + add_channel_to_message(message, 'channel_inbox'); + } + }); _.each(data.channel_ids, function (channel_id) { var channel = chat_manager.get_channel(channel_id); if (channel) { @@ -468,7 +474,7 @@ var chat_manager = { }, mark_all_as_read: function (channel) { if ((!channel && needaction_counter) || (channel && channel.needaction_counter)) { - return MessageModel.call('mark_all_as_read', channel ? [[channel.id]] : [[]]); + return MessageModel.call('mark_all_as_read', channel ? [[channel.id]] : []); } return $.when(); }, |
