diff options
| author | Aaron Bohy <aab@odoo.com> | 2015-10-01 10:41:12 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2015-10-01 14:00:20 +0200 |
| commit | 0d91339b7bcb68781ee4b11c5474ed853f8c62bd (patch) | |
| tree | e6aa5c2073ca652ea940ecd8551ad67559676b89 | |
| parent | 0e2dd225f6d62e705ceedc10bb8a3017c9c661a6 (diff) | |
[IMP] mail: increase needaction counter on new message notification
At least, when someone mentions a user in a message posted in a channel, a
notification is sent by the server that a new message just arrived in that
channel. Client side, we then decide whether or not this message should appear
in the Inbox as well. In the positive case, we can increase the needaction
counter.
Problem remains for messages sent from chatters and by using the mail icon in
the systray, as for those ones, no notification at all is sent by the server.
| -rw-r--r-- | addons/mail/static/src/js/chat_manager.js | 6 | ||||
| -rw-r--r-- | addons/mail/static/src/js/client_action.js | 8 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/client_action.xml | 10 |
3 files changed, 19 insertions, 5 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 1fd25c9a7b1..a6eb4d7d264 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -410,7 +410,11 @@ function init () { // new message in a channel var message = notification[1]; var channel_id = message.channel_ids[0]; - add_message(message, { channel_id: channel_id, show_notification: true} ); + message = add_message(message, { channel_id: channel_id, show_notification: true} ); + if (_.contains(message.channel_ids, 'channel_inbox')) { + needaction_counter = needaction_counter + 1; + chat_manager.bus.trigger('update_needaction', needaction_counter); + } } if (model === 'res.partner') { var chat_session = notification[1]; diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index 1239492c38b..025b9d88f1d 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -192,7 +192,7 @@ var ChatAction = Widget.extend(ControlPanelMixin, { chat_manager.bus.on('anyone_listening', self, function (channel, query) { query.is_displayed = query.is_displayed || channel.id === self.channel_id; }); - chat_manager.bus.on('update_needaction', self, self.render_sidebar); + chat_manager.bus.on('update_needaction', self, self.on_update_needaction); }); }, @@ -429,6 +429,12 @@ var ChatAction = Widget.extend(ControlPanelMixin, { this.set_channel(channel.id); } }, + on_update_needaction: function () { + var $needaction_badge = QWeb.render("mail.chat.SidebarNeedaction", { + needaction_counter: chat_manager.get_needaction_counter() + }); + this.$('.o_mail_sidebar_needaction').replaceWith($needaction_badge); + }, on_click_button_invite: function () { var channel = chat_manager.get_channel(this.channel_id); diff --git a/addons/mail/static/src/xml/client_action.xml b/addons/mail/static/src/xml/client_action.xml index 8a23b33333e..e4e80250b92 100644 --- a/addons/mail/static/src/xml/client_action.xml +++ b/addons/mail/static/src/xml/client_action.xml @@ -16,9 +16,7 @@ <div t-name="mail.chat.Sidebar" class="o_mail_chat_sidebar"> <div class="o_mail_chat_channel_item" data-channel-id="channel_inbox"> @ Inbox - <span t-attf-class="badge pull-right #{(!needaction_counter ? 'hide' : '')}"> - <t t-esc="needaction_counter"/> - </span> + <t t-call="mail.chat.SidebarNeedaction"/> </div> <div class="o_mail_chat_channel_item" data-channel-id="channel_starred"> <span class="fa fa-star-o"/> Starred @@ -81,6 +79,12 @@ </t> --> </div> + <t t-name="mail.chat.SidebarNeedaction"> + <span t-attf-class="o_mail_sidebar_needaction badge pull-right #{(!needaction_counter ? 'hide' : '')}"> + <t t-esc="needaction_counter"/> + </span> + </t> + <!-- Buttons of the Control Panel --> |
