gfds
This commit is contained in:
@@ -3873,19 +3873,24 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Mark all read
|
||||
// Mark all read (current tab only)
|
||||
if (sMarkAll) {
|
||||
sMarkAll.addEventListener('click', async () => {
|
||||
try {
|
||||
const tab = sActiveTab || 'user';
|
||||
const csrfToken = window.f0ckSession?.csrf_token || window.scrollerCsrf || '';
|
||||
await fetch('/api/notifications/read', {
|
||||
await fetch('/api/notifications/read?tab=' + encodeURIComponent(tab), {
|
||||
method: 'POST',
|
||||
headers: { ...(csrfToken ? { 'X-CSRF-Token': csrfToken } : {}) }
|
||||
});
|
||||
updateScrollerNotifBadge(0);
|
||||
sCachedNotifs = sCachedNotifs.map(n => ({ ...n, is_read: true }));
|
||||
// Mark only the active tab's cached notifications as read
|
||||
const tabCheck = tab === 'user' ? isUserType : (tab === 'system' ? isSystemType : () => false);
|
||||
sCachedNotifs = sCachedNotifs.map(n => tabCheck(n.type) ? { ...n, is_read: true } : n);
|
||||
updateScrollerTabBadges(sCachedNotifs);
|
||||
renderScrollerNotifs(filterByTab(sCachedNotifs, sActiveTab));
|
||||
// Update overall badge
|
||||
const totalUnread = sCachedNotifs.filter(n => !n.is_read).length;
|
||||
updateScrollerNotifBadge(totalUnread);
|
||||
} catch (e) {}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user