import React, { useEffect, useState } from 'react' function actorLabel(item) { if (!item?.actor) { return item?.type === 'notification' ? 'System' : 'Someone' } return item.actor.username ? `@${item.actor.username}` : item.actor.name || 'User' } function describeActivity(item) { switch (item?.type) { case 'comment': return item?.context?.artwork_title ? `commented on ${item.context.artwork_title}` : 'commented on your artwork' case 'new_follower': return 'started following you' case 'notification': return item?.message || 'sent a notification' default: return item?.message || 'shared new activity' } } function activityIcon(type) { switch (type) { case 'comment': return 'fa-solid fa-comment-dots' case 'new_follower': return 'fa-solid fa-user-plus' case 'notification': return 'fa-solid fa-bell' default: return 'fa-solid fa-bolt' } } function timeLabel(dateString) { const date = new Date(dateString) if (Number.isNaN(date.getTime())) { return 'just now' } return date.toLocaleString() } export default function ActivityFeed() { const [items, setItems] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState('') useEffect(() => { let cancelled = false async function load() { try { setLoading(true) const response = await window.axios.get('/api/activity', { params: { filter: 'my', per_page: 8, }, }) if (!cancelled) { setItems(Array.isArray(response.data?.data) ? response.data.data : []) setError('') } } catch (err) { if (!cancelled) { setError('Could not load activity right now.') } } finally { if (!cancelled) { setLoading(false) } } } load() return () => { cancelled = true } }, []) return (

Live activity

Activity Feed

Recent followers, artwork comments, and notifications that deserve your attention.

Recent actions
{loading ?

Loading activity...

: null} {error ?

{error}

: null} {!loading && !error && items.length === 0 ? (

No recent activity yet.

New followers, comments, and notifications will appear here as they happen.

) : null} {!loading && !error && items.length > 0 ? (
{items.map((item) => (
{item.actor?.avatar ? ( {actorLabel(item)} ) : ( )}

{actorLabel(item)}{' '} {describeActivity(item)}

{item.message && item.type !== 'notification' ? (

{item.message}

) : null}
{timeLabel(item.created_at)}
{item.context?.artwork_url ? ( View artwork ) : null}
))}
) : null}
) }