Ignore:
Timestamp:
06/25/2026 05:22:51 AM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
4c9c60b
Parents:
d7526bd
Message:

feat(fediverse): real bell badge for unseen notifications

Track a per-site 'seen' timestamp (app_settings); the top-bar bell shows a badge
with the count of fediverse notifications newer than last-seen, and opening
/meldingen marks them seen (clears the badge). Replaces the dead user_notifications
counter.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    rd7526bd re951b7c  
    169169  } catch { /* non-fatal */ }
    170170  return out;
     171}
     172
     173// Notifications "seen" tracking → a real bell badge. Stored per site in app_settings.
     174export 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}
     180export 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; }
    171188}
    172189
     
    919936  getNotifications, listBlocks, isBlockedAny, blockTarget, unblock,
    920937  deliverWithRetry, enqueueDelivery, processDeliveryQueue, startDeliveryWorker,
    921   getReplyUris,
     938  getReplyUris, markNotificationsSeen, countUnseenNotifications,
    922939};
Note: See TracChangeset for help on using the changeset viewer.