From 7ecea242f205c45f316c13abcfb12ea5b173bca5 Mon Sep 17 00:00:00 2001 From: john Date: Sun, 10 Aug 2025 18:41:45 +0200 Subject: [PATCH] add post reaction timeline --- src/app/feed/components/PostTimeline.tsx | 31 ++++++++++++++++++++++++ src/app/feed/pages/PostPage.tsx | 8 +++--- 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/app/feed/components/PostTimeline.tsx diff --git a/src/app/feed/components/PostTimeline.tsx b/src/app/feed/components/PostTimeline.tsx new file mode 100644 index 0000000..9fe6ddc --- /dev/null +++ b/src/app/feed/components/PostTimeline.tsx @@ -0,0 +1,31 @@ +import { PostReaction } from '../posts/posts.ts' +import { Temporal } from '@js-temporal/polyfill' + +interface PostTimelineProps { + reactions: PostReaction[] +} + +export function PostTimeline({ reactions }: PostTimelineProps) { + return ( +
+ {reactions.map((reaction) => ( +
+
+ {Temporal.Now.instant().toLocaleString('en-AU', { + year: 'numeric', + month: 'numeric', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + })} +
+
+ @{reaction.authorName}  + did  + {reaction.emoji} +
+
+ ))} +
+ ) +} diff --git a/src/app/feed/pages/PostPage.tsx b/src/app/feed/pages/PostPage.tsx index f81b89a..d8929d3 100644 --- a/src/app/feed/pages/PostPage.tsx +++ b/src/app/feed/pages/PostPage.tsx @@ -10,6 +10,7 @@ import { useTranslations } from '../../i18n/translations.ts' import { usePostViewModel } from '../posts/usePostViewModel.ts' import { Temporal } from '@js-temporal/polyfill' import { useUserStore } from '../../user/user.ts' +import { PostTimeline } from '../components/PostTimeline.tsx' interface PostPageProps { postsService: PostsService @@ -17,11 +18,11 @@ interface PostPageProps { export default function PostPage({ postsService }: PostPageProps) { const { postId } = useParams<{ postId: string }>() - const { posts, setPosts, addReaction, reactions, removeReaction } = usePostViewModel() + const { posts, setPosts, addReaction, reactions: _reactions, removeReaction } = usePostViewModel() const { t } = useTranslations() const username = useUserStore((state) => state.user?.username) - const post = posts.at(0) + const reactions = (post?.postId ? _reactions[post.postId] : []) ?? [] useEffect(() => { if (!postId) return @@ -59,11 +60,12 @@ export default function PostPage({ postsService }: PostPageProps) {
+
)}