Notifications card: show unread count bubble via the shared poll
pollNotifications now updates every .notif-badge (sidebar nav + homepage card) from the same /api/notifications source, so the card bubble shows the unread count and clears in lockstep with the sidebar. Add a badge to the card; scope the collapsed-only badge positioning to the sidebar. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -120,7 +120,7 @@
|
|||||||
font-size: 11px; font-weight: 700;
|
font-size: 11px; font-weight: 700;
|
||||||
display: inline-flex; align-items: center; justify-content: center;
|
display: inline-flex; align-items: center; justify-content: center;
|
||||||
}
|
}
|
||||||
html.collapsed .notif-badge {
|
html.collapsed .side-nav .notif-badge {
|
||||||
position: absolute; top: 5px; right: 8px; margin: 0;
|
position: absolute; top: 5px; right: 8px; margin: 0;
|
||||||
min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px;
|
min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px;
|
||||||
}
|
}
|
||||||
@@ -336,10 +336,12 @@
|
|||||||
const r = await fetch('/api/notifications', { headers: { 'X-Token': t } });
|
const r = await fetch('/api/notifications', { headers: { 'X-Token': t } });
|
||||||
if (!r.ok) return;
|
if (!r.ok) return;
|
||||||
const d = await r.json();
|
const d = await r.json();
|
||||||
const b = document.getElementById('notif-badge');
|
const label = d.unread > 99 ? '99+' : d.unread;
|
||||||
if (!b) return;
|
// update every badge (sidebar nav + homepage card) from the one source
|
||||||
if (d.unread > 0) { b.textContent = d.unread > 99 ? '99+' : d.unread; b.style.display = 'inline-flex'; }
|
document.querySelectorAll('.notif-badge').forEach(b => {
|
||||||
else { b.style.display = 'none'; }
|
if (d.unread > 0) { b.textContent = label; b.style.display = 'inline-flex'; }
|
||||||
|
else { b.style.display = 'none'; }
|
||||||
|
});
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
pollNotifications();
|
pollNotifications();
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
<a class="tile" href="/notifications">
|
<a class="tile" href="/notifications">
|
||||||
<span class="t-ico">🔔</span>
|
<span class="t-ico">🔔</span>
|
||||||
<span class="t-title">Notifications</span>
|
<span class="t-title">Notifications</span>
|
||||||
|
<span class="notif-badge" style="display:none;"></span>
|
||||||
</a>
|
</a>
|
||||||
<a class="tile" href="/settings">
|
<a class="tile" href="/settings">
|
||||||
<span class="t-ico">⚙️</span>
|
<span class="t-ico">⚙️</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user