Skip to content
Snippets Groups Projects
Commit d60f8e32 authored by Alexandre Kühn's avatar Alexandre Kühn
Browse files

[IMP] mail: turn 'Messaging/isNotificationBlocked' into field


Task-2793280

closes odoo/odoo#86453

Signed-off-by: default avatarAlexandre Kühn (aku) <aku@odoo.com>
parent 5c5ef04a
No related branches found
No related tags found
No related merge requests found
......@@ -4,28 +4,7 @@ import { registerMessagingComponent } from '@mail/utils/messaging_component';
const { Component } = owl;
export class NotificationAlert extends Component {
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* @returns {boolean}
*/
get isNotificationBlocked() {
if (!this.messaging) {
return false;
}
const windowNotification = this.messaging.browser.Notification;
return (
windowNotification &&
windowNotification.permission !== "granted" &&
!this.messaging.isNotificationPermissionDefault
);
}
}
export class NotificationAlert extends Component {}
Object.assign(NotificationAlert, {
props: {},
......
......@@ -4,7 +4,7 @@
<t t-name="mail.NotificationAlert" owl="1">
<div class="o_NotificationAlert" t-attf-class="{{ className }}" t-ref="root">
<t t-if="messaging">
<center t-if="isNotificationBlocked" class="o_notification_alert alert alert-primary">
<center t-if="messaging.isNotificationBlocked" class="o_notification_alert alert alert-primary">
Odoo Push notifications have been blocked. Go to your browser settings to allow them.
</center>
</t>
......
......@@ -176,6 +176,18 @@ registerModel({
_computeIsCurrentUserGuest() {
return Boolean(!this.currentPartner && this.currentGuest);
},
/**
* @private
* @returns {boolean}
*/
_computeIsNotificationBlocked() {
const windowNotification = this.browser.Notification;
return (
windowNotification &&
windowNotification.permission !== 'granted' &&
!this.isNotificationPermissionDefault
);
},
/**
* @private
* @returns {EventBus}
......@@ -299,6 +311,9 @@ registerModel({
isInitialized: attr({
default: false,
}),
isNotificationBlocked: attr({
compute: '_computeIsNotificationBlocked',
}),
/**
* States whether browser Notification Permission is currently in its
* 'default' state. This means it is allowed to make a request to the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment