summaryrefslogtreecommitdiff
path: root/addons/mail_bot/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail_bot/static/src')
-rw-r--r--addons/mail_bot/static/src/js/mailbot_service.js32
-rw-r--r--addons/mail_bot/static/src/js/systray_messaging_menu.js5
2 files changed, 21 insertions, 16 deletions
diff --git a/addons/mail_bot/static/src/js/mailbot_service.js b/addons/mail_bot/static/src/js/mailbot_service.js
index a75780ab090..8863ea94ba0 100644
--- a/addons/mail_bot/static/src/js/mailbot_service.js
+++ b/addons/mail_bot/static/src/js/mailbot_service.js
@@ -23,6 +23,11 @@ var MailBotService = AbstractService.extend({
}, 2*60*1000);
}
},
+
+ //--------------------------------------------------------------------------
+ // Public
+ //--------------------------------------------------------------------------
+
/**
* Get the previews related to the OdooBot (conversation not included).
* For instance, when there is no conversation with OdooBot and OdooBot has
@@ -33,25 +38,28 @@ var MailBotService = AbstractService.extend({
* 'mail.Preview' template.
*/
getPreviews: function (filter) {
- var previews = [];
- if (this.hasRequest() && (filter === 'mailbox_inbox' || !filter)) {
- previews.push({
- title: _t("OdooBot has a request"),
- imageSRC: "/mail/static/src/img/odoobot.png",
- status: 'bot',
- body: _t("Enable desktop notifications to chat"),
- id: 'request_notification',
- unreadCounter: 1,
- });
+ if (!this.isRequestingForNativeNotifications()) {
+ return [];
+ }
+ if (filter && filter !== 'mailbox_inbox') {
+ return [];
}
+ var previews = [{
+ title: _t("OdooBot has a request"),
+ imageSRC: "/mail/static/src/img/odoobot.png",
+ status: 'bot',
+ body: _t("Enable desktop notifications to chat"),
+ id: 'request_notification',
+ unreadCounter: 1,
+ }];
return previews;
},
/**
- * Tell whether OdooBot has a request or not.
+ * Tell whether OdooBot is requesting to enable push notifications.
*
* @returns {boolean}
*/
- hasRequest: function () {
+ isRequestingForNativeNotifications: function () {
return window.Notification && window.Notification.permission === "default";
},
});
diff --git a/addons/mail_bot/static/src/js/systray_messaging_menu.js b/addons/mail_bot/static/src/js/systray_messaging_menu.js
index 05c0ee54f24..f7e64ff751e 100644
--- a/addons/mail_bot/static/src/js/systray_messaging_menu.js
+++ b/addons/mail_bot/static/src/js/systray_messaging_menu.js
@@ -22,7 +22,7 @@ return MessagingMenu.include({
*/
_computeCounter: function () {
var counter = this._super.apply(this, arguments);
- if (this.call('mailbot_service', 'hasRequest')) {
+ if (this.call('mailbot_service', 'isRequestingForNativeNotifications')) {
counter++;
}
return counter;
@@ -59,9 +59,6 @@ return MessagingMenu.include({
if (value !== 'granted') {
this.call('bus_service', 'sendNotification', _t('Permission denied'),
_t('Odoo will not have the permission to send native notifications on this device.'));
- } else {
- this.call('bus_service', 'sendNotification', _t('Yay, push notifications are enabled!'),
- _t('Odoo has now the permission to send you native notifications on this device.'));
}
this._updateCounter();
},