summaryrefslogtreecommitdiff
path: root/addons/mail_bot/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail_bot/static/src/js')
-rw-r--r--addons/mail_bot/static/src/js/mailbot_service.js36
-rw-r--r--addons/mail_bot/static/src/js/systray_messaging_menu.js1
2 files changed, 28 insertions, 9 deletions
diff --git a/addons/mail_bot/static/src/js/mailbot_service.js b/addons/mail_bot/static/src/js/mailbot_service.js
index 8863ea94ba0..5312e5d5129 100644
--- a/addons/mail_bot/static/src/js/mailbot_service.js
+++ b/addons/mail_bot/static/src/js/mailbot_service.js
@@ -12,15 +12,9 @@ var MailBotService = AbstractService.extend({
* @override
*/
start: function () {
- var self = this;
+ this._hasRequest = (window.Notification && window.Notification.permission === "default") || false;
if ('odoobot_initialized' in session && ! session.odoobot_initialized) {
- setTimeout(function () {
- session.odoobot_initialized = true;
- self._rpc({
- model: 'mail.channel',
- method: 'init_odoobot',
- });
- }, 2*60*1000);
+ this._showOdoobotTimeout();
}
},
@@ -60,7 +54,31 @@ var MailBotService = AbstractService.extend({
* @returns {boolean}
*/
isRequestingForNativeNotifications: function () {
- return window.Notification && window.Notification.permission === "default";
+ return this._hasRequest;
+ },
+ /**
+ * Called when user either accepts or refuses push notifications.
+ */
+ removeRequest: function () {
+ this._hasRequest = false;
+ },
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ _showOdoobotTimeout: function () {
+ var self = this;
+ setTimeout(function () {
+ session.odoobot_initialized = true;
+ self._rpc({
+ model: 'mail.channel',
+ method: 'init_odoobot',
+ });
+ }, 2*60*1000);
},
});
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 f7e64ff751e..3b7ee2f9e38 100644
--- a/addons/mail_bot/static/src/js/systray_messaging_menu.js
+++ b/addons/mail_bot/static/src/js/systray_messaging_menu.js
@@ -56,6 +56,7 @@ return MessagingMenu.include({
* @param {string} value
*/
_handleResponseNotificationPermission: function (value) {
+ this.call('mailbot_service', 'removeRequest');
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.'));