feat: show unread count in page title

This commit is contained in:
Erwan Leboucher committed 2026-07-16 09:16:36 +02:00
1 parent ae69b8bbaf
commit e89de8cb58
1 file changed
+22
@@ -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) {
<PageZoomFeature />
<PrivacyBlurFeature />
<FaviconUpdater />
<PageTitleUpdater />
<InviteNotifications />
<MessageNotifications />
<BackgroundNotifications />