From 1e0e95782480d9757ca72cb86dba26655c8b8334 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:48:23 +0100 Subject: [PATCH] feat(mobile): route notification taps through mobile screen stack --- .../src/components/NotificationController.tsx | 5 +++- packages/web/src/platform/notifications.ts | 23 +++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/web/src/components/NotificationController.tsx b/packages/web/src/components/NotificationController.tsx index fc218805..65e356fa 100644 --- a/packages/web/src/components/NotificationController.tsx +++ b/packages/web/src/components/NotificationController.tsx @@ -61,7 +61,10 @@ export function NotificationController() { const body = message.content ? message.content.replace(/[*_~`>#\-\[\]]/g, '').slice(0, 100) : 'Sent an attachment'; - sendNotification(displayName, body); + sendNotification(displayName, body, { + channelId: message.channelId ?? message.dmChannelId, + spaceId: message.dmChannelId ? '@me' : undefined, + }); break; // one notification per batch } } diff --git a/packages/web/src/platform/notifications.ts b/packages/web/src/platform/notifications.ts index 6cd6802e..01a4e0f7 100644 --- a/packages/web/src/platform/notifications.ts +++ b/packages/web/src/platform/notifications.ts @@ -1,10 +1,29 @@ import { isElectron } from './platform'; +import { useUIStore } from '../stores/uiStore'; -export function sendNotification(title: string, body: string): void { +interface NotificationOptions { + channelId?: string; + spaceId?: string; +} + +export function sendNotification(title: string, body: string, options?: NotificationOptions): void { if (isElectron()) { window.backspace!.showNotification(title, body); } else if ('Notification' in window && Notification.permission === 'granted') { - new Notification(title, { body, icon: '/icons/icon-192.png' }); + const notification = new Notification(title, { body, icon: '/icons/icon-192.png' }); + notification.onclick = () => { + window.focus(); + const { channelId, spaceId } = options ?? {}; + if (channelId) { + const isMobile = useUIStore.getState().isMobile; + if (isMobile) { + useUIStore.getState().pushMobileScreen('channel-chat', { + channelId, + spaceId: spaceId || '@me', + }); + } + } + }; } }