A platform for community discussion. Free, open, simple.
FIX: prevent desktop notification callbacks on mobile (#28527)
David Battersby910bfaf5f55d
diff --git a/app/assets/javascripts/discourse/app/instance-initializers/subscribe-user-notifications.js b/app/assets/javascripts/discourse/app/instance-initializers/subscribe-user-notifications.jsindex 1b60f0cc1d3..2b4f680ffae 100644--- a/app/assets/javascripts/discourse/app/instance-initializers/subscribe-user-notifications.js+++ b/app/assets/javascripts/discourse/app/instance-initializers/subscribe-user-notifications.js@@ -3,7 +3,7 @@ import {alertChannel,disable as disableDesktopNotifications,init as initDesktopNotifications,- onNotification,+ onNotification as onDesktopNotification,} from "discourse/lib/desktop-notifications";import {isPushNotificationsEnabled,@@ -260,11 +260,13 @@ export default {@bindonAlert(data) {- return onNotification(- data,- this.siteSettings,- this.currentUser,- this.appEvents- );+ if (this.site.desktopView) {+ return onDesktopNotification(+ data,+ this.siteSettings,+ this.currentUser,+ this.appEvents+ );+ }},};diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.jsindex bc605f20636..e775a59460d 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js@@ -1,7 +1,7 @@import Service, { service } from "@ember/service";import {alertChannel,- onNotification,+ onNotification as onDesktopNotification,} from "discourse/lib/desktop-notifications";import { withPluginApi } from "discourse/lib/plugin-api";import { isTesting } from "discourse-common/config/environment";@@ -13,6 +13,7 @@ export default class ChatNotificationManager extends Service {@service chatStateManager;@service currentUser;@service appEvents;+ @service site;_subscribedToCore = true;_subscribedToChat = false;@@ -149,12 +150,14 @@ export default class ChatNotificationManager extends Service {return;}- return onNotification(- data,- this.siteSettings,- this.currentUser,- this.appEvents- );+ if (this.site.desktopView) {+ return onDesktopNotification(+ data,+ this.siteSettings,+ this.currentUser,+ this.appEvents+ );+ }}_shouldRun() {