diff --git a/src/app/features/settings/notifications/SystemNotification.tsx b/src/app/features/settings/notifications/SystemNotification.tsx index 3d7827889..1ececb70d 100644 --- a/src/app/features/settings/notifications/SystemNotification.tsx +++ b/src/app/features/settings/notifications/SystemNotification.tsx @@ -37,7 +37,6 @@ import { } from './PushNotifications'; import { DeregisterAllPushersSetting } from './DeregisterPushNotifications'; import { - deriveLegacyPushFlags, disableNativePush, enableNativePush, getSupportedNotificationTransportModes, @@ -76,13 +75,6 @@ function getBackgroundPushPlatform(isTauriRuntime: boolean): BackgroundPushPlatf return 'desktop'; } -function deriveLegacyPushSync(input: { enabled: boolean; provider: BackgroundPushKind | null }): { - usePushNotifications: boolean; - useUnifiedPush: boolean; -} { - return deriveLegacyPushFlags(input.enabled, input.provider); -} - export async function switchBackgroundPushTransport(params: { previousKind: BackgroundPushKind | null; activate: () => Promise; @@ -352,11 +344,6 @@ function BackgroundPushNotificationSetting() { ); const [useRichPushPayloads] = useSetting(settingsAtom, 'useRichPushPayloads'); const [pushNotifyUrlOverride] = useSetting(settingsAtom, 'pushNotifyUrlOverride'); - const [legacyPushNotifications, setLegacyPushNotifications] = useSetting( - settingsAtom, - 'usePushNotifications' - ); - const [legacyUnifiedPush, setLegacyUnifiedPush] = useSetting(settingsAtom, 'useUnifiedPush'); const pushSubAtom = useAtom(pushSubscriptionAtom); const [upEndpoint, setUpEndpoint] = useAtom(unifiedPushEndpointAtom); const unifiedPushStateRef = useRef(upEndpoint); @@ -407,28 +394,6 @@ function BackgroundPushNotificationSetting() { unifiedPushStateRef.current = upEndpoint; }, [upEndpoint]); - useEffect(() => { - const sync = deriveLegacyPushSync({ - enabled: backgroundPushEnabled, - provider: backgroundPushEnabled ? (backgroundPushProvider ?? preferredKind) : null, - }); - - if (legacyPushNotifications !== sync.usePushNotifications) { - setLegacyPushNotifications(sync.usePushNotifications); - } - if (legacyUnifiedPush !== sync.useUnifiedPush) { - setLegacyUnifiedPush(sync.useUnifiedPush); - } - }, [ - backgroundPushEnabled, - backgroundPushProvider, - preferredKind, - legacyPushNotifications, - legacyUnifiedPush, - setLegacyPushNotifications, - setLegacyUnifiedPush, - ]); - useEffect(() => { if (runtimePlatform !== 'android') { setAvailableDistributors([]); diff --git a/src/app/hooks/useAppVisibility.ts b/src/app/hooks/useAppVisibility.ts index 97053c106..1b7fe399d 100644 --- a/src/app/hooks/useAppVisibility.ts +++ b/src/app/hooks/useAppVisibility.ts @@ -14,7 +14,7 @@ const debugLog = createDebugLogger('AppVisibility'); export function useAppVisibility(mx: MatrixClient | undefined) { const clientConfig = useClientConfig(); - const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications'); + const [backgroundPushEnabled] = useSetting(settingsAtom, 'backgroundPushEnabled'); const pushSubAtom = useAtom(pushSubscriptionAtom); const isMobile = isMobileOrTablet(); @@ -43,12 +43,12 @@ export function useAppVisibility(mx: MatrixClient | undefined) { if (!mx) return undefined; const handleVisibilityForNotifications = (isVisible: boolean) => { - togglePusher(mx, clientConfig, isVisible, usePushNotifications, pushSubAtom, isMobile); + togglePusher(mx, clientConfig, isVisible, backgroundPushEnabled, pushSubAtom, isMobile); }; appEvents.onVisibilityChange = handleVisibilityForNotifications; return () => { appEvents.onVisibilityChange = null; }; - }, [mx, clientConfig, usePushNotifications, pushSubAtom, isMobile]); + }, [mx, clientConfig, backgroundPushEnabled, pushSubAtom, isMobile]); } diff --git a/src/app/pages/client/BackgroundNotifications.tsx b/src/app/pages/client/BackgroundNotifications.tsx index 6aa9f2e72..f362a1730 100644 --- a/src/app/pages/client/BackgroundNotifications.tsx +++ b/src/app/pages/client/BackgroundNotifications.tsx @@ -141,14 +141,14 @@ export function BackgroundNotifications() { const sessions = useAtomValue(sessionsAtom); const [activeSessionId, setActiveSessionId] = useAtom(activeSessionIdAtom); const [showNotifications] = useSetting(settingsAtom, 'useInAppNotifications'); - const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications'); + const [backgroundPushEnabled] = useSetting(settingsAtom, 'backgroundPushEnabled'); const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds'); const [showMessageContent] = useSetting(settingsAtom, 'showMessageContentInNotifications'); const [showEncryptedMessageContent] = useSetting( settingsAtom, 'showMessageContentInEncryptedNotifications' ); - const shouldRunBackgroundNotifications = showNotifications || usePushNotifications; + const shouldRunBackgroundNotifications = showNotifications || backgroundPushEnabled; const nicknames = useAtomValue(nicknamesAtom); const nicknamesRef = useRef(nicknames); nicknamesRef.current = nicknames; diff --git a/src/app/pages/client/client-non-ui/badging.tsx b/src/app/pages/client/client-non-ui/badging.tsx index 6bad98518..d8c1ae0d1 100644 --- a/src/app/pages/client/client-non-ui/badging.tsx +++ b/src/app/pages/client/client-non-ui/badging.tsx @@ -51,7 +51,7 @@ export function PageTitleUpdater() { export function FaviconUpdater() { const roomToUnread = useAtomValue(roomToUnreadAtom); - const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications'); + const [backgroundPushEnabled] = useSetting(settingsAtom, 'backgroundPushEnabled'); const [faviconForMentionsOnly] = useSetting(settingsAtom, 'faviconForMentionsOnly'); const registration = useAtomValue(registrationAtom); @@ -83,7 +83,7 @@ export function FaviconUpdater() { } else { navigator.clearAppBadge(); } - if (usePushNotifications && registration) { + if (backgroundPushEnabled && registration) { if (total === 0) { // All rooms read — clear every notification. registration.getNotifications().then((notifs) => notifs.forEach((n) => n.close())); @@ -104,7 +104,7 @@ export function FaviconUpdater() { } catch { // Likely Firefox/Gecko-based and doesn't support badging API } - }, [roomToUnread, usePushNotifications, registration, faviconForMentionsOnly]); + }, [roomToUnread, backgroundPushEnabled, registration, faviconForMentionsOnly]); return null; } diff --git a/src/app/pages/client/client-non-ui/notifications.tsx b/src/app/pages/client/client-non-ui/notifications.tsx index 4a22c4b0d..e3b0b0bb3 100644 --- a/src/app/pages/client/client-non-ui/notifications.tsx +++ b/src/app/pages/client/client-non-ui/notifications.tsx @@ -80,7 +80,7 @@ export function InviteNotifications() { const navigate = useNavigate(); const [showSystemNotifications] = useSetting(settingsAtom, 'useSystemNotifications'); - const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications'); + const [backgroundPushEnabled] = useSetting(settingsAtom, 'backgroundPushEnabled'); const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds'); const [backgroundNotificationSounds] = useSetting(settingsAtom, 'backgroundNotificationSounds'); @@ -128,7 +128,7 @@ export function InviteNotifications() { if (invites.length <= perviousInviteLen || mx.getSyncState() !== SyncState.Syncing) return; // SW push (via Sygnal) handles invite notifications when the app is backgrounded. - if (!isPageVisible() && usePushNotifications) return; + if (!isPageVisible() && backgroundPushEnabled) return; const withSound = notificationSound && (isWindowFocused() || backgroundNotificationSounds); let soundOnNotification = false; @@ -154,7 +154,7 @@ export function InviteNotifications() { invites, perviousInviteLen, showSystemNotifications, - usePushNotifications, + backgroundPushEnabled, notificationSound, backgroundNotificationSounds, notify,