mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 20:28:10 +08:00
FEATURE: Add support for desktop push notifications in core (#19375)
* FEATURE: Add support for desktop push notifications in core Default to push for live notifications on desktop if available and `enable_desktop_push_notifications` site setting set to true. This removes the need for desktop-push-notifications plugin. * DEV: Ensure live notifications are enabled explicitly Allow a user with push notification access who has directly enabled notifications via the browser settings to trigger push subscription flow.
This commit is contained in:
parent
4edeb7d9eb
commit
382757d1bd
@ -55,6 +55,7 @@ export default Component.extend({
|
||||
return isGrantedPermission ? !notificationsDisabled : false;
|
||||
},
|
||||
|
||||
// TODO: (selase) getter should consistently return a boolean
|
||||
@discourseComputed
|
||||
isEnabledPush: {
|
||||
set(value) {
|
||||
@ -82,11 +83,25 @@ export default Component.extend({
|
||||
|
||||
isEnabled: or("isEnabledDesktop", "isEnabledPush"),
|
||||
|
||||
isPushNotificationsPreferred() {
|
||||
if (!this.site.mobileView) {
|
||||
@discourseComputed("isEnabled", "isEnabledPush", "notificationsDisabled")
|
||||
isSubscribed(isEnabled, isEnabledPush, notificationsDisabled) {
|
||||
if (!isEnabled) {
|
||||
return false;
|
||||
}
|
||||
return isPushNotificationsSupported();
|
||||
|
||||
if (this.isPushNotificationsPreferred()) {
|
||||
return isEnabledPush === "subscribed";
|
||||
} else {
|
||||
return notificationsDisabled === "";
|
||||
}
|
||||
},
|
||||
|
||||
isPushNotificationsPreferred() {
|
||||
return (
|
||||
(this.site.mobileView ||
|
||||
this.siteSettings.enable_desktop_push_notifications) &&
|
||||
isPushNotificationsSupported()
|
||||
);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -5,7 +5,7 @@
|
||||
<DButton @icon="bell-slash" @class="btn-default" @label="user.desktop_notifications.perm_denied_btn" @action={{action "recheckPermission"}} @disabled="true" />
|
||||
{{i18n "user.desktop_notifications.perm_denied_expl"}}
|
||||
{{else}}
|
||||
{{#if this.isEnabled}}
|
||||
{{#if this.isSubscribed}}
|
||||
<DButton @icon="far-bell-slash" @class="btn-default" @label="user.desktop_notifications.disable" @action={{action "turnoff"}} />
|
||||
{{else}}
|
||||
<DButton @icon="far-bell" @class="btn-default" @label="user.desktop_notifications.enable" @action={{action "turnon"}} />
|
||||
|
@ -2357,6 +2357,7 @@ en:
|
||||
|
||||
push_notifications_prompt: "Display user consent prompt."
|
||||
push_notifications_icon: "The badge icon that appears in the notification corner. A 96×96 monochromatic PNG with transparency is recommended."
|
||||
enable_desktop_push_notifications: "Enable desktop push notifications"
|
||||
|
||||
base_font: "Base font to use for most text on the site. Themes can override via the `--font-family` CSS custom property."
|
||||
heading_font: "Font to use for headings on the site. Themes can override via the `--heading-font-family` CSS custom property."
|
||||
|
@ -348,6 +348,9 @@ basic:
|
||||
push_notifications_icon:
|
||||
default: ""
|
||||
type: upload
|
||||
enable_desktop_push_notifications:
|
||||
default: true
|
||||
client: true
|
||||
short_title:
|
||||
default: ""
|
||||
max: 12
|
||||
|
Loading…
x
Reference in New Issue
Block a user