import { useEffect, useRef } from "react"; import { useUserStore } from "../../stores/user"; import { useNotificationsStore } from "../../stores/notifications"; import { NoteCard } from "../feed/NoteCard"; export function NotificationsView() { const { pubkey, loggedIn } = useUserStore(); const { notifications, unreadCount, lastSeenAt, loading, fetchNotifications, markAllRead, } = useNotificationsStore(); // Capture lastSeenAt at mount time so unread highlights persist during this view session const prevLastSeenAtRef = useRef(lastSeenAt); useEffect(() => { if (!pubkey) return; fetchNotifications(pubkey).then(() => { setTimeout(() => markAllRead(), 500); }); }, [pubkey]); if (!loggedIn || !pubkey) { return (
Log in to see notifications.
); } return (

Notifications

{unreadCount > 0 && ( )}
{loading && notifications.length === 0 && (
Loading notifications…
)} {!loading && notifications.length === 0 && (
No mentions yet.
)} {notifications.map((event) => { const isUnread = (event.created_at ?? 0) > prevLastSeenAtRef.current; return (
); })}
); }