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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 14 deletions

View File

@ -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 {
@bind
onAlert(data) {
return onNotification(
data,
this.siteSettings,
this.currentUser,
this.appEvents
);
if (this.site.desktopView) {
return onDesktopNotification(
data,
this.siteSettings,
this.currentUser,
this.appEvents
);
}
},
};

View File

@ -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() {