summaryrefslogtreecommitdiff
path: root/addons/mail_bot/static/src/js/mailbot_service.js
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-12-05 14:35:09 +0000
committerAlexandre Kühn <aku@odoo.com>2018-12-06 14:51:28 +0000
commit64f044761aa52bc4fb87821de415aef5a8fea0d9 (patch)
tree6b3596121a89563951469c76f4003c8b823f772d /addons/mail_bot/static/src/js/mailbot_service.js
parentf3bd34b870ea63025213b9964c34c8ba38443a79 (diff)
[IMP] bus, mail, mail_bot: improved native notification
With this commit, no push notification is sent to user when to acknowledge that he just has accepted them. Also, on native push notifications, the Odoo Bot icon now has a transparent background. Task-ID 1881001
Diffstat (limited to 'addons/mail_bot/static/src/js/mailbot_service.js')
-rw-r--r--addons/mail_bot/static/src/js/mailbot_service.js32
1 files changed, 20 insertions, 12 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";
},
});