"use client"; import { FormEvent, useCallback, useEffect, useRef, useState } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; import { useAccount } from "@/contexts/AccountContext"; import { formatRingLabel, getRing } from "@/lib/forumRings"; import { addReply, displayScore, getThread, isReadOnlyThread, type ForumThread, } from "@/lib/forumState"; import { ThreadVoteColumn } from "@/components/forum/ThreadVoteColumn"; export default function VoidAggregatePostPage() { const params = useParams(); const id = typeof params.id === "string" ? params.id : ""; const { user, hydrated: accountReady } = useAccount(); const prefilledAuthor = useRef(false); const [thread, setThread] = useState(null); const [body, setBody] = useState(""); const [author, setAuthor] = useState(""); const [replyErr, setReplyErr] = useState(null); const [copied, setCopied] = useState(false); const refresh = useCallback(() => { setThread(getThread(id) ?? null); }, [id]); useEffect(() => { refresh(); }, [refresh]); useEffect(() => { if (!accountReady || !user || prefilledAuthor.current) return; setAuthor(user.displayName); prefilledAuthor.current = true; }, [accountReady, user]); const onReply = (e: FormEvent) => { e.preventDefault(); setReplyErr(null); if (!id) return; if (addReply(id, author, body)) { setBody(""); refresh(); } else { setReplyErr("Staff-locked — open a new thread to discuss."); } }; if (!id) { return

Invalid post.

; } if (!thread) { return (

Post not found.

← front page
); } const t = thread; const ring = getRing(t.topicSlug); const locked = isReadOnlyThread(t.id); const copyPermalink = async () => { try { await navigator.clipboard.writeText(window.location.href); setCopied(true); window.setTimeout(() => setCopied(false), 2000); } catch { setCopied(false); } }; return (
{locked ? (
Staff-controlled thread. Replies are closed on hub-seeded posts — open a new topic in{" "} r/{ring?.shortName ?? t.topicSlug} {" "} to continue the conversation.
) : null}
{ring ? (

r/{ring.shortName} · {displayScore(t)} points

) : null}

{t.title}

Posted by {t.author || "Anonymous"} · {new Date(t.ts).toLocaleString()}

{t.body}

Comments · {t.replies.length}

{t.replies.map((r) => (

{r.author} · {new Date(r.ts).toLocaleString()}

{r.body}

))}
{locked ? null : (

Add comment

{replyErr ?

{replyErr}

: null} setAuthor(e.target.value)} />