FIX: prevent desktop notification callbacks on mobile (#28527)

This commit is contained in:
David Battersby
2024-08-26 09:49:49 +04:00
committed by GitHub
parent 0803e2d237
commit 910bfaf5f5
2 changed files with 19 additions and 14 deletions

View File

@@ -3,7 +3,7 @@ import {
alertChannel, alertChannel,
disable as disableDesktopNotifications, disable as disableDesktopNotifications,
init as initDesktopNotifications, init as initDesktopNotifications,
onNotification, onNotification as onDesktopNotification,
} from "discourse/lib/desktop-notifications"; } from "discourse/lib/desktop-notifications";
import { import {
isPushNotificationsEnabled, isPushNotificationsEnabled,
@@ -260,11 +260,13 @@ export default {
@bind @bind
onAlert(data) { onAlert(data) {
return onNotification( if (this.site.desktopView) {
data, return onDesktopNotification(
this.siteSettings, data,
this.currentUser, this.siteSettings,
this.appEvents this.currentUser,
); this.appEvents
);
}
}, },
}; };

View File

@@ -1,7 +1,7 @@
import Service, { service } from "@ember/service"; import Service, { service } from "@ember/service";
import { import {
alertChannel, alertChannel,
onNotification, onNotification as onDesktopNotification,
} from "discourse/lib/desktop-notifications"; } from "discourse/lib/desktop-notifications";
import { withPluginApi } from "discourse/lib/plugin-api"; import { withPluginApi } from "discourse/lib/plugin-api";
import { isTesting } from "discourse-common/config/environment"; import { isTesting } from "discourse-common/config/environment";
@@ -13,6 +13,7 @@ export default class ChatNotificationManager extends Service {
@service chatStateManager; @service chatStateManager;
@service currentUser; @service currentUser;
@service appEvents; @service appEvents;
@service site;
_subscribedToCore = true; _subscribedToCore = true;
_subscribedToChat = false; _subscribedToChat = false;
@@ -149,12 +150,14 @@ export default class ChatNotificationManager extends Service {
return; return;
} }
return onNotification( if (this.site.desktopView) {
data, return onDesktopNotification(
this.siteSettings, data,
this.currentUser, this.siteSettings,
this.appEvents this.currentUser,
); this.appEvents
);
}
} }
_shouldRun() { _shouldRun() {