diff options
| author | Julien Legros <jle@odoo.com> | 2016-01-25 11:26:27 +0100 |
|---|---|---|
| committer | Julien Legros <jle@odoo.com> | 2016-01-25 11:26:27 +0100 |
| commit | e5e7c4c1217c04d93820cf6007fd8ceed30d0cfa (patch) | |
| tree | 0c475b2aa9f8f1b92f1550466cc189f1ba36230b /addons/mail/static/src/js | |
| parent | 85b39df834c8689fd22e1a56d780af703a61909d (diff) | |
| parent | 6872aae8ef9c1a1fc6a8283aa9d12ce3a6859157 (diff) | |
[MERGE] forward port of branch 9.0 up to 6872aae
Diffstat (limited to 'addons/mail/static/src/js')
| -rw-r--r-- | addons/mail/static/src/js/chat_manager.js | 42 | ||||
| -rw-r--r-- | addons/mail/static/src/js/client_action.js | 6 |
2 files changed, 32 insertions, 16 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 17462d8f6d4..aff51c721cf 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -464,21 +464,35 @@ var channel_seen = _.throttle(function (channel) { // Notification handlers // --------------------------------------------------------------------------------- -function on_notification (notification) { - var model = notification[0][1]; - if (model === 'ir.needaction') { - // new message in the inbox - on_needaction_notification(notification[1]); - } else if (model === 'mail.channel') { - // new message in a channel - on_channel_notification(notification[1]); - } else if (model === 'res.partner') { - // channel joined/left, message marked as read/(un)starred, chat open/closed - on_partner_notification(notification[1]); - } else if (model === 'bus.presence') { - // update presence of users - on_presence_notification(notification[1]); +function on_notification (notifications) { + // sometimes, the web client receives unsubscribe notification and an extra + // notification on that channel. This is then followed by an attempt to + // rejoin the channel that we just left. The next few lines remove the + // extra notification to prevent that situation to occur. + var unsubscribed_notif = _.find(notifications, function (notif) { + return notif[1].info === "unsubscribe"; + }); + if (unsubscribed_notif) { + notifications = _.reject(notifications, function (notif) { + return notif[0][1] === "mail.channel" && notif[0][2] === unsubscribed_notif[1].id; + }); } + _.each(notifications, function (notification) { + var model = notification[0][1]; + if (model === 'ir.needaction') { + // new message in the inbox + on_needaction_notification(notification[1]); + } else if (model === 'mail.channel') { + // new message in a channel + on_channel_notification(notification[1]); + } else if (model === 'res.partner') { + // channel joined/left, message marked as read/(un)starred, chat open/closed + on_partner_notification(notification[1]); + } else if (model === 'bus.presence') { + // update presence of users + on_presence_notification(notification[1]); + } + }); } function on_needaction_notification (message) { diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index 46190c1dd0b..38cc26e8997 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -214,7 +214,9 @@ var ChatAction = Widget.extend(ControlPanelMixin, { var def1 = this.thread.appendTo(this.$('.o_mail_chat_content')); var def2 = this.basic_composer.appendTo(this.$('.o_mail_chat_content')); var def3 = this.extended_composer.appendTo(this.$('.o_mail_chat_content')); - var def4 = this.searchview.appendTo($("<div>")); + var def4 = this.searchview.appendTo($("<div>")).then(function () { + self.$searchview_buttons = self.searchview.$buttons.contents(); + }); this.render_sidebar(); @@ -486,7 +488,7 @@ var ChatAction = Widget.extend(ControlPanelMixin, { cp_content: { $buttons: this.$buttons, $searchview: this.searchview.$el, - $searchview_buttons: this.searchview.$buttons.contents(), + $searchview_buttons: this.$searchview_buttons, }, searchview: this.searchview, }); |
