[IMP] mail: turn 'Messaging/isNotificationBlocked' into field
Task-2793280 closes odoo/odoo#86453 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user