diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-01-09 15:44:05 +0000 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-01-09 15:56:53 +0000 |
| commit | 8aa8548d8ab68feb13f3bde51c557db84877e809 (patch) | |
| tree | 930790c1c84a4412db777986f6b2077808560d95 /addons/mail_bot/static/src/js/mailbot_service.js | |
| parent | 55a48e341580a6a400c36b6ba0d7b12ff9997f12 (diff) | |
| parent | 3e4138deaa23b3631dc3fce33cd6d1b3be28ffbd (diff) | |
[MERGE] forward port branch 12.0 up to 3e4138deaa2
closes odoo/odoo#30045
Diffstat (limited to 'addons/mail_bot/static/src/js/mailbot_service.js')
| -rw-r--r-- | addons/mail_bot/static/src/js/mailbot_service.js | 36 |
1 files changed, 27 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); }, }); |
