From b840bf3e9fe5d0f89a45d70c3ee0874b3a550bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 19 Aug 2020 15:49:52 +0000 Subject: [PATCH] [FIX] im_livechat: silently ignore display notifs in external lib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-2322857 closes odoo/odoo#57031 X-original-commit: 963f73c61a4e70d0f4f9bf5ac429aff44f0cae0e Signed-off-by: Sébastien Theys (seb) Signed-off-by: Alexandre Kühn (aku) --- .../static/src/legacy/public_livechat.js | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/addons/im_livechat/static/src/legacy/public_livechat.js b/addons/im_livechat/static/src/legacy/public_livechat.js index 4f14fbb06f7..35512fca51d 100644 --- a/addons/im_livechat/static/src/legacy/public_livechat.js +++ b/addons/im_livechat/static/src/legacy/public_livechat.js @@ -233,10 +233,21 @@ var LivechatButton = Widget.extend({ } def.then(function (livechatData) { if (!livechatData || !livechatData.operator_pid) { - self.displayNotification({ - message: _t("No available collaborator, please try again later."), - sticky: true - }); + try { + self.displayNotification({ + message: _t("No available collaborator, please try again later."), + sticky: true, + }); + } catch (err) { + /** + * Failure in displaying notification happens when + * notification service doesn't exist, which is the case in + * external lib. We don't want notifications in external + * lib at the moment because they use bootstrap toast and + * we don't want to include boostrap in external lib. + */ + console.warn(_t("No available collaborator, please try again later.")); + } } else { self._livechat = new WebsiteLivechat({ parent: self, @@ -328,10 +339,22 @@ var LivechatButton = Widget.extend({ .rpc('/mail/chat_post', { uuid: this._livechat.getUUID(), message_content: message.content }) .then(function (messageId) { if (!messageId) { - self.displayNotification({ - message: _t("Session expired... Please refresh and try again."), - sticky: true - }); + try { + self.displayNotification({ + message: _t("Session expired... Please refresh and try again."), + sticky: true, + }); + } catch (err) { + /** + * Failure in displaying notification happens when + * notification service doesn't exist, which is the case + * in external lib. We don't want notifications in + * external lib at the moment because they use bootstrap + * toast and we don't want to include boostrap in + * external lib. + */ + console.warn(_t("Session expired... Please refresh and try again.")); + } self._closeChat(); } self._chatWindow.scrollToBottom();