[FIX] im_livechat: silently ignore display notifs in external lib

Task-2322857

closes odoo/odoo#57031

X-original-commit: 963f73c61a4e70d0f4f9bf5ac429aff44f0cae0e
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Alexandre Kühn
2020-09-03 12:44:35 +00:00
parent 9eee59b843
commit b840bf3e9f
@@ -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();