Changeset e951b7c in Klonkt
- Timestamp:
- 06/25/2026 05:22:51 AM (3 months ago)
- Branches:
- main
- Children:
- 4c9c60b
- Parents:
- d7526bd
- Location:
- src
- Files:
-
- 4 edited
-
middleware/render.js (modified) (2 diffs)
-
routes/posts.js (modified) (1 diff)
-
services/ActivityPubService.js (modified) (2 diffs)
-
views/partials/topnav.ejs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/middleware/render.js
rd7526bd re951b7c 19 19 import { getSetting } from '../services/SettingsService.js'; 20 20 import { isPremium as isPremiumInstance, premiumEnabled, premiumUnlocked } from '../services/PatreonService.js'; 21 import { unreadCount as notifUnreadCount } from '../services/NotificationService.js';21 import ActivityPubService from '../services/ActivityPubService.js'; 22 22 import { audioEnabled as audioFeatureEnabled } from '../config/features.js'; 23 23 import { PLATFORMS as PLATFORMS_CATALOG } from '../services/PlatformIcons.js'; … … 118 118 langs: LANGS.map((c) => ({ code: c, name: LANG_NAMES[c], active: c === _lang })), 119 119 timezone: getSetting('timezone') || '', 120 notifUnread: _u ? notifUnreadCount(_u.id) : 0,120 notifUnread: (canManageFedi && _site) ? ActivityPubService.countUnseenNotifications(_site.slug) : 0, 121 121 userOwnsSite, 122 122 canSeeBeheer, -
src/routes/posts.js
rd7526bd re951b7c 581 581 const site = res.locals.site; 582 582 const items = site ? ActivityPubService.getNotifications(site.slug, 80) : []; 583 if (site) ActivityPubService.markNotificationsSeen(site.slug); // viewing = seen → clears the bell badge 583 584 renderPage(req, res, 'pages/fedi-notifications', { pageTitle: 'Meldingen', bodyClass: 'on-special', items }); 584 585 }); -
src/services/ActivityPubService.js
rd7526bd re951b7c 169 169 } catch { /* non-fatal */ } 170 170 return out; 171 } 172 173 // Notifications "seen" tracking → a real bell badge. Stored per site in app_settings. 174 export function markNotificationsSeen(slug) { 175 try { 176 db.prepare("INSERT INTO app_settings (key, value, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP) ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = CURRENT_TIMESTAMP") 177 .run(`fedi_notif_seen:${slug}`, new Date().toISOString()); 178 } catch { /* non-fatal */ } 179 } 180 export function countUnseenNotifications(slug) { 181 try { 182 const row = db.prepare('SELECT value FROM app_settings WHERE key = ?').get(`fedi_notif_seen:${slug}`); 183 const seen = row ? Date.parse(row.value) : 0; 184 let n = 0; 185 for (const it of getNotifications(slug, 50)) { if (Date.parse(it.created_at) > seen) n++; } 186 return n; 187 } catch { return 0; } 171 188 } 172 189 … … 919 936 getNotifications, listBlocks, isBlockedAny, blockTarget, unblock, 920 937 deliverWithRetry, enqueueDelivery, processDeliveryQueue, startDeliveryWorker, 921 getReplyUris, 938 getReplyUris, markNotificationsSeen, countUnseenNotifications, 922 939 }; -
src/views/partials/topnav.ejs
rd7526bd re951b7c 103 103 hx-get="/meldingen?partial=1" hx-target="#pcms-main" hx-swap="innerHTML" hx-push-url="/meldingen" hx-indicator="#pcms-loading"> 104 104 <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/></svg> 105 <% if (typeof notifUnread !== 'undefined' && notifUnread > 0) { %><span class="notif-badge"><%= notifUnread > 9 ? '9+' : notifUnread %></span><% } %> 105 106 </a> 106 107 <% } %>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)