From 2169ef8e64923e98e22b0f6c17a2806c62a91719 Mon Sep 17 00:00:00 2001 From: Karolis Kalantojus Date: Sun, 21 Apr 2019 00:03:38 +0300 Subject: [PATCH] [FIX] web_notify attempt to fix void messages (#1249) It seems besides the custom channels provided in this addon it also catches messages from other channels. E.g. in this case it seems the void popup is triggered by these activity creation bus messages. **Steps to reproduce** Odoo commit: could reproduce on 5e8b667951 and 4da82776ff OCA/web commit: 2465278 * Install crm and web_notify modules * Create an activity for yourself (tried for admin user) * Empty popup appears **Attempt to solve** It seems the bus handles all messages non exclusively. I've hacked in a conditional to handle only messages from web_notify addon, but its unclear wether this does not break something else. --- web_notify/static/src/js/web_client.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/web_notify/static/src/js/web_client.js b/web_notify/static/src/js/web_client.js index d1e1ff5a..ef6b8287 100644 --- a/web_notify/static/src/js/web_client.js +++ b/web_notify/static/src/js/web_client.js @@ -19,6 +19,13 @@ odoo.define('web_notify.WebClient', function (require) { this.channel_warning = 'notify_warning_' + session.uid; this.channel_info = 'notify_info_' + session.uid; this.channel_default = 'notify_default_' + session.uid; + this.all_channels = [ + this.channel_success, + this.channel_danger, + this.channel_warning, + this.channel_info, + this.channel_default, + ]; this.call('bus_service', 'addChannel', this.channel_success); this.call('bus_service', 'addChannel', this.channel_danger); this.call('bus_service', 'addChannel', this.channel_warning); @@ -32,9 +39,14 @@ odoo.define('web_notify.WebClient', function (require) { bus_notification: function (notifications) { var self = this; _.each(notifications, function (notification) { - // Not used: var channel = notification[0]; + var channel = notification[0]; var message = notification[1]; - self.on_message(message); + if ( + self.all_channels != null && + self.all_channels.indexOf(channel) > -1 + ) { + self.on_message(message); + } }); }, on_message: function (message) {