File size: 1,032 Bytes
1f21206 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import { useChatStore } from '../stores/chatStore'
import { useSessionStore } from '../stores/sessionStore'
import { SCHEDULED_TAB_ID, useTabStore } from '../stores/tabStore'
import {
installDesktopNotificationClickListener,
type DesktopNotificationTarget,
} from './desktopNotifications'
const SCHEDULED_TAB_TITLE = 'Scheduled Tasks'
export function openDesktopNotificationTarget(target: DesktopNotificationTarget): void {
if (target.type === 'scheduled') {
useTabStore.getState().openTab(SCHEDULED_TAB_ID, SCHEDULED_TAB_TITLE, 'scheduled')
return
}
const knownTitle = useSessionStore
.getState()
.sessions
.find((session) => session.id === target.sessionId)
?.title
useTabStore.getState().openTab(target.sessionId, target.title || knownTitle || 'Session', 'session')
useChatStore.getState().connectToSession(target.sessionId)
}
export function installDesktopNotificationNavigation(): Promise<() => void> {
return installDesktopNotificationClickListener(openDesktopNotificationTarget)
}
|