"use client"; import { useEffect, useMemo, useState } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; import ForumFeedToolbar from "@/components/forum/ForumFeedToolbar"; import { ForumPostCard } from "@/components/forum/ForumPostCard"; import { threadMatchesQuery } from "@/lib/forumFeedFilter"; import { getRing } from "@/lib/forumRings"; import { isPinnedThread, loadForum, sortPinnedThreads, type ForumThread, } from "@/lib/forumState"; import { sortThreads, type ForumSortMode } from "@/lib/forumSort"; export default function VoidAggregateRingPage() { const params = useParams(); const slug = typeof params.slug === "string" ? params.slug : ""; const ring = getRing(slug); const [threads, setThreads] = useState([]); const [sort, setSort] = useState("hot"); const [search, setSearch] = useState(""); const [hydrated, setHydrated] = useState(false); const [, setVoteBump] = useState(0); useEffect(() => { setThreads(loadForum()); setHydrated(true); }, []); const filtered = useMemo(() => { if (!ring) return []; return threads .filter((t) => t.topicSlug === ring.slug) .filter((t) => threadMatchesQuery(t, search)); }, [threads, ring, search]); const { pinnedList, feedList } = useMemo(() => { const pinned = sortPinnedThreads(filtered.filter(isPinnedThread)); const rest = filtered.filter((t) => !isPinnedThread(t)); return { pinnedList: pinned, feedList: sortThreads(rest, sort) }; }, [filtered, sort]); const totalShown = pinnedList.length + feedList.length; if (!ring) { return (

Unknown ring · /r/{slug}

← front page
); } return (

r/{ring.shortName}

{ring.title}

{ring.about}

{ring.members.toLocaleString()} members {ring.activeNow.toLocaleString()} est. online
Post in r/{ring.shortName} ← All rings
Global feed } /> {!hydrated ? (

Loading…

) : totalShown === 0 ? (

No threads match in r/{ring.shortName}.{" "} Start one .

) : (
{pinnedList.length ? (

Pinned here

{pinnedList.map((t) => ( setVoteBump((x) => x + 1)} /> ))}
) : null} {feedList.length ? (
{pinnedList.length ? (

Threads

) : null} {feedList.map((t) => ( setVoteBump((x) => x + 1)} /> ))}
) : null}
)}
); }