From ce792e78cabeefbacc69b362e512c68872c52aa9 Mon Sep 17 00:00:00 2001 From: Nils Hamerlinck Date: Mon, 24 Feb 2020 17:43:31 +0700 Subject: [PATCH] [IMP] web_notify: add channels only if not done already --- web_notify/static/src/js/web_client.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/web_notify/static/src/js/web_client.js b/web_notify/static/src/js/web_client.js index ef6b82871..3bc96f1d6 100644 --- a/web_notify/static/src/js/web_client.js +++ b/web_notify/static/src/js/web_client.js @@ -26,15 +26,26 @@ odoo.define('web_notify.WebClient', function (require) { 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); - this.call('bus_service', 'addChannel', this.channel_info); - this.call('bus_service', 'addChannel', this.channel_default); + + // startPolling to get this new tab registered, + // in order to be able to call isMasterTab + this.call('bus_service', 'startPolling'); + + // - no need to add channels again if it was done already + // - this is also a workaround for the infinite loop issue + // that occures when user logs in as a different user + // while still being logged in 2+ other tabs + if(this.call('bus_service', 'isMasterTab')) { + this.call('bus_service', 'addChannel', this.channel_success); + this.call('bus_service', 'addChannel', this.channel_danger); + this.call('bus_service', 'addChannel', this.channel_warning); + this.call('bus_service', 'addChannel', this.channel_info); + this.call('bus_service', 'addChannel', this.channel_default); + } + this.call( 'bus_service', 'on', 'notification', this, this.bus_notification); - this.call('bus_service', 'startPolling'); }, bus_notification: function (notifications) { var self = this;