This commit is contained in:
2026-03-20 21:17:26 +01:00
parent 1a62fcb81d
commit 29c3ff8572
229 changed files with 13147 additions and 2577 deletions

View File

@@ -1,11 +1,30 @@
import React, { useEffect, useState } from 'react'
function actorLabel(item) {
if (!item.actor) {
return 'System'
if (!item?.user) {
return 'Someone'
}
return item.actor.username ? `@${item.actor.username}` : item.actor.name || 'User'
return item.user.username ? `@${item.user.username}` : item.user.name || 'User'
}
function describeActivity(item) {
const artworkTitle = item?.artwork?.title || 'an artwork'
const mentionTarget = item?.mentioned_user?.username || item?.mentioned_user?.name || 'someone'
const reactionLabel = item?.reaction?.label || 'reacted'
switch (item?.type) {
case 'comment':
return `commented on ${artworkTitle}`
case 'reply':
return `replied on ${artworkTitle}`
case 'reaction':
return `${reactionLabel.toLowerCase()} on ${artworkTitle}`
case 'mention':
return `mentioned @${mentionTarget} on ${artworkTitle}`
default:
return 'shared new activity'
}
}
function timeLabel(dateString) {
@@ -28,9 +47,15 @@ export default function ActivityFeed() {
async function load() {
try {
setLoading(true)
const response = await window.axios.get('/api/dashboard/activity')
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) {
@@ -77,14 +102,12 @@ export default function ActivityFeed() {
>
<div className="flex items-start justify-between gap-2">
<p className="text-sm text-gray-100">
<span className="font-semibold text-white">{actorLabel(item)}</span> {item.message}
<span className="font-semibold text-white">{actorLabel(item)}</span> {describeActivity(item)}
</p>
{item.is_unread ? (
<span className="rounded-full bg-cyan-500/20 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-cyan-200">
unread
</span>
) : null}
</div>
{item.comment?.body ? (
<p className="mt-2 line-clamp-2 text-xs text-gray-300">{item.comment.body}</p>
) : null}
<p className="mt-2 text-xs text-gray-400">{timeLabel(item.created_at)}</p>
</article>
))}