feat(notifications): Refactor notification system and consolidate interaction handlers
- Remove dedicated bot owner notification utility in favor of unified notification system - Update all interaction endpoints (follow, like, mention, repost) to use consolidated notification flow - Refactor notification route to handle all interaction types through single endpoint - Update posts endpoints to trigger notifications through unified system - Add database migration snapshot for notification schema changes - Simplify notification logic by removing redundant bot owner notification module - Improve notification consistency across all user interactions and post operations
This commit is contained in:
@@ -12,6 +12,7 @@ export function Sidebar() {
|
||||
const { user, isAdmin } = useAuth();
|
||||
const pathname = usePathname();
|
||||
const [customLogoUrl, setCustomLogoUrl] = useState<string | null | undefined>(undefined);
|
||||
const [unreadCount, setUnreadCount] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/node')
|
||||
@@ -24,6 +25,25 @@ export function Sidebar() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
// Fetch unread notification count
|
||||
useEffect(() => {
|
||||
if (!user) return;
|
||||
|
||||
const fetchUnread = () => {
|
||||
fetch('/api/notifications?unread=true&limit=50')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
setUnreadCount(data.notifications?.length || 0);
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
fetchUnread();
|
||||
// Poll every 30 seconds
|
||||
const interval = setInterval(fetchUnread, 30000);
|
||||
return () => clearInterval(interval);
|
||||
}, [user]);
|
||||
|
||||
// Home is exact match
|
||||
const isHome = pathname === '/';
|
||||
|
||||
@@ -46,9 +66,20 @@ export function Sidebar() {
|
||||
<span>Explore</span>
|
||||
</Link>
|
||||
{user && (
|
||||
<Link href="/notifications" className={`nav-item ${pathname?.startsWith('/notifications') ? 'active' : ''}`}>
|
||||
<Link href="/notifications" className={`nav-item ${pathname?.startsWith('/notifications') ? 'active' : ''}`} style={{ position: 'relative' }}>
|
||||
<BellIcon />
|
||||
<span>Notifications</span>
|
||||
{unreadCount > 0 && (
|
||||
<span style={{
|
||||
position: 'absolute',
|
||||
top: '8px',
|
||||
left: '24px',
|
||||
width: '8px',
|
||||
height: '8px',
|
||||
background: 'var(--error)',
|
||||
borderRadius: '50%',
|
||||
}} />
|
||||
)}
|
||||
</Link>
|
||||
)}
|
||||
{user && (
|
||||
|
||||
Reference in New Issue
Block a user