From 5301ef876d2bee53b4a5370b968969e7c498df75 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 24 Jun 2025 17:36:14 -0700 Subject: [PATCH] Fix notification badge for global chat --- src/app/notifications.ts | 8 ++++++++ src/app/routes.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/app/notifications.ts b/src/app/notifications.ts index c583c80f..e1ed0762 100644 --- a/src/app/notifications.ts +++ b/src/app/notifications.ts @@ -9,6 +9,7 @@ import { makeChatPath, makeThreadPath, makeCalendarPath, + makeSpaceChatPath, makeRoomPath, } from "@app/routes" import {chats, getUrlsForEvent, userRoomsByUrl, repositoryStore} from "@app/state" @@ -75,8 +76,10 @@ export const notifications = derived( const spacePath = makeSpacePath(url) const threadPath = makeThreadPath(url) const calendarPath = makeCalendarPath(url) + const messagesPath = makeSpaceChatPath(url) const threadEvents = allThreadEvents.filter(e => $getUrlsForEvent(e.id).includes(url)) const calendarEvents = allCalendarEvents.filter(e => $getUrlsForEvent(e.id).includes(url)) + const messagesEvents = allMessageEvents.filter(e => $getUrlsForEvent(e.id).includes(url)) if (hasNotification(threadPath, threadEvents[0])) { paths.add(spacePath) @@ -88,6 +91,11 @@ export const notifications = derived( paths.add(calendarPath) } + if (hasNotification(messagesPath, messagesEvents[0])) { + paths.add(spacePath) + paths.add(messagesPath) + } + const commentsByThreadId = groupBy( e => getTagValue("E", e.tags), threadEvents.filter(spec({kind: COMMENT})), diff --git a/src/app/routes.ts b/src/app/routes.ts index 95d10299..01827c96 100644 --- a/src/app/routes.ts +++ b/src/app/routes.ts @@ -35,6 +35,8 @@ export const makeChatPath = (pubkeys: string[]) => `/chat/${makeChatId(pubkeys)} export const makeRoomPath = (url: string, room: string) => `/spaces/${encodeRelay(url)}/${room}` +export const makeSpaceChatPath = (url: string) => makeRoomPath(url, "chat") + export const makeThreadPath = (url: string, eventId?: string) => makeSpacePath(url, "threads", eventId)