diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index dce5ff80..82c2015b 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -43,7 +43,7 @@ function App() { const { healthy, error: healthError, checking: healthChecking, retry: retryHealth } = useContractHealth(); const userAddress = getMainnetAddress(userData); - const { notifications, unreadCount, markAllRead, loading: notificationsLoading } = useNotifications(userAddress); + const { notifications, unreadCount, lastSeenTimestamp, markAllRead, loading: notificationsLoading } = useNotifications(userAddress); const { isOwner } = useAdmin(userAddress); usePageTitle(); @@ -137,6 +137,7 @@ function App() { authLoading={authLoading} notifications={notifications} unreadCount={unreadCount} + lastSeenTimestamp={lastSeenTimestamp} onMarkNotificationsRead={markAllRead} notificationsLoading={notificationsLoading} apiReachable={healthy} diff --git a/frontend/src/components/Header.jsx b/frontend/src/components/Header.jsx index 04e78857..f7456988 100644 --- a/frontend/src/components/Header.jsx +++ b/frontend/src/components/Header.jsx @@ -24,7 +24,7 @@ import { Sun, Moon } from 'lucide-react'; * @param {Function} props.onMarkNotificationsRead - Callback to mark all read. * @param {boolean} props.notificationsLoading - Whether notifications are loading. */ -export default function Header({ userData, onAuth, authLoading, notifications, unreadCount, onMarkNotificationsRead, notificationsLoading, apiReachable = null }) { +export default function Header({ userData, onAuth, authLoading, notifications, unreadCount, lastSeenTimestamp, onMarkNotificationsRead, notificationsLoading, apiReachable = null }) { const { theme, toggleTheme } = useTheme(); const isOnline = useOnlineStatus(); @@ -85,6 +85,7 @@ export default function Header({ userData, onAuth, authLoading, notifications, u unreadCount={unreadCount} onMarkRead={onMarkNotificationsRead} loading={notificationsLoading} + lastSeenTimestamp={lastSeenTimestamp} /> )} diff --git a/frontend/src/components/NotificationBell.jsx b/frontend/src/components/NotificationBell.jsx index fde165a0..9259d055 100644 --- a/frontend/src/components/NotificationBell.jsx +++ b/frontend/src/components/NotificationBell.jsx @@ -2,7 +2,7 @@ import { useState, useRef, useEffect } from 'react'; import { formatSTX, formatAddress } from '../lib/utils'; import { Bell } from 'lucide-react'; -export default function NotificationBell({ notifications, unreadCount, onMarkRead, loading }) { +export default function NotificationBell({ notifications, unreadCount, onMarkRead, loading, lastSeenTimestamp }) { const [open, setOpen] = useState(false); const dropdownRef = useRef(null); @@ -25,6 +25,11 @@ export default function NotificationBell({ notifications, unreadCount, onMarkRea const truncateAddr = (addr) => formatAddress(addr, 6, 4); + const isUnread = (tip) => { + if (lastSeenTimestamp == null) return false; + return tip.timestamp > lastSeenTimestamp; + }; + return (