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 4bdc9566b8dc807ae62f74c309ef8eb48681e708..06acd309a48e919b16b11446150064d1776124a3 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 6ab0b1414f1691aa4eacdb0ea5cdf5308e9ded34..4587454b44cc89b27c134bb8c89968af6c6b2014 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 @@ <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> diff --git a/addons/mail/static/src/models/messaging.js b/addons/mail/static/src/models/messaging.js index 9d0a0dca498987bb2efb0c98cd6998295cfbbd81..7e1f06ab6e01453829da5414a73a130539353a26 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