[FIX] mail_bot: odoobot waits 1 week between notification requests
Steps to reproduce: - install mail_bot - wait for odoobot to ask you if you want to receive notifications - do not select "grant" or "deny", click the closing cross Previous behavior: Odoobot would consider that you denied the request Current behavior: Odoobot waits 1 week and will ask you again opw-2186299 closes odoo/odoo#46697 X-original-commit: b7254ecaeee7f8fa564ca2059f119f5d12404af6 Signed-off-by: mightyjol <jhk-odoo@users.noreply.github.com>
This commit is contained in:
committed by
Nicolas Martinelli
parent
49fc39b202
commit
a1e87bbf23
@@ -4,6 +4,7 @@ odoo.define('mail_bot.MailBotService', function (require) {
|
||||
var AbstractService = require('web.AbstractService');
|
||||
var core = require('web.core');
|
||||
var session = require('web.session');
|
||||
var localStorage = require('web.local_storage');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
@@ -13,9 +14,13 @@ var MailBotService = AbstractService.extend({
|
||||
*/
|
||||
start: function () {
|
||||
this._hasRequest = (window.Notification && window.Notification.permission === "default") || false;
|
||||
var lastRequestTime = localStorage.getItem('odoobot_notification_last_request_time');
|
||||
if ('odoobot_initialized' in session && ! session.odoobot_initialized) {
|
||||
this._showOdoobotTimeout();
|
||||
}
|
||||
else if (lastRequestTime !== null && (new Date().getTime() - parseInt(lastRequestTime) > 7*24*60*60*1000)) {
|
||||
this._showOdoobotTimeout();
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -57,10 +57,14 @@ return MessagingMenu.include({
|
||||
*/
|
||||
_handleResponseNotificationPermission: function (value) {
|
||||
this.call('mailbot_service', 'removeRequest');
|
||||
if (value !== 'granted') {
|
||||
localStorage.removeItem('odoobot_notification_last_request_time');
|
||||
if (value === 'denied') {
|
||||
this.call('bus_service', 'sendNotification', _t('Permission denied'),
|
||||
_t('Odoo will not have the permission to send native notifications on this device.'));
|
||||
}
|
||||
else if (value === 'default') {
|
||||
localStorage.setItem('odoobot_notification_last_request_time', new Date().getTime());
|
||||
}
|
||||
this._updateCounter();
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user