diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-12-05 14:35:09 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-12-06 14:51:28 +0000 |
| commit | 64f044761aa52bc4fb87821de415aef5a8fea0d9 (patch) | |
| tree | 6b3596121a89563951469c76f4003c8b823f772d /addons/mail_bot/static/src | |
| parent | f3bd34b870ea63025213b9964c34c8ba38443a79 (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')
| -rw-r--r-- | addons/mail_bot/static/src/js/mailbot_service.js | 32 | ||||
| -rw-r--r-- | addons/mail_bot/static/src/js/systray_messaging_menu.js | 5 |
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(); }, |
