diff --git a/addons/mail/static/src/components/notification_alert/notification_alert.js b/addons/mail/static/src/components/notification_alert/notification_alert.js index 4bdc9566b8d..06acd309a48 100644 --- a/addons/mail/static/src/components/notification_alert/notification_alert.js +++ b/addons/mail/static/src/components/notification_alert/notification_alert.js @@ -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: {}, diff --git a/addons/mail/static/src/components/notification_alert/notification_alert.xml b/addons/mail/static/src/components/notification_alert/notification_alert.xml index 6ab0b1414f1..4587454b44c 100644 --- a/addons/mail/static/src/components/notification_alert/notification_alert.xml +++ b/addons/mail/static/src/components/notification_alert/notification_alert.xml @@ -4,7 +4,7 @@
-
+
Odoo Push notifications have been blocked. Go to your browser settings to allow them.
diff --git a/addons/mail/static/src/models/messaging.js b/addons/mail/static/src/models/messaging.js index 9d0a0dca498..7e1f06ab6e0 100644 --- a/addons/mail/static/src/models/messaging.js +++ b/addons/mail/static/src/models/messaging.js @@ -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