From e89de8cb5830b5da3718da08a3cfe02719ff798d Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Wed, 15 Jul 2026 23:38:34 +0200 Subject: [PATCH] feat: show unread count in page title --- src/app/pages/client/ClientNonUIFeatures.tsx | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index 52ac07ef2..f62a2880c 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -107,6 +107,27 @@ function PageZoomFeature() { return null; } +// Updates document.title with an unread count. +function PageTitleUpdater() { + const roomToUnread = useAtomValue(roomToUnreadAtom); + const [faviconForMentionsOnly] = useSetting(settingsAtom, 'faviconForMentionsOnly'); + + useEffect(() => { + let total = 0; + let highlightTotal = 0; + roomToUnread.forEach((unread) => { + if (unread.from === null) { + total += unread.total; + highlightTotal += unread.highlight; + } + }); + const count = faviconForMentionsOnly ? highlightTotal : total; + document.title = count > 0 ? `(${count}) Sable Client` : 'Sable Client'; + }, [roomToUnread, faviconForMentionsOnly]); + + return null; +} + function FaviconUpdater() { const roomToUnread = useAtomValue(roomToUnreadAtom); const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications'); @@ -904,6 +925,7 @@ export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) { +