notification-click.ts 384 B

12345678910111213
  1. let nav: ((href: string) => void) | undefined
  2. export const setNavigate = (fn: (href: string) => void) => {
  3. nav = fn
  4. }
  5. export const handleNotificationClick = (href?: string) => {
  6. window.focus()
  7. if (!href) return
  8. if (nav) return nav(href)
  9. console.warn("notification-click: navigate function not set, falling back to window.location.assign")
  10. window.location.assign(href)
  11. }