diff --git a/thoughts-frontend/app/page.tsx b/thoughts-frontend/app/page.tsx index 20ee490..c5c1a33 100644 --- a/thoughts-frontend/app/page.tsx +++ b/thoughts-frontend/app/page.tsx @@ -1,11 +1,13 @@ // app/page.tsx import { cookies } from "next/headers"; -import { getFeed, getMe, getUserProfile, Me } from "@/lib/api"; +import { getFeed, getMe, getUserProfile, Me, Thought } from "@/lib/api"; import { ThoughtCard } from "@/components/thought-card"; import { PostThoughtForm } from "@/components/post-thought-form"; import { Button } from "@/components/ui/button"; import Link from "next/link"; import { PopularTags } from "@/components/popular-tags"; +import { ThoughtThread } from "@/components/thought-thread"; +import { buildThoughtThreads } from "@/lib/utils"; // This is now an async Server Component export default async function Home() { @@ -32,6 +34,10 @@ async function FeedPage({ token }: { token: string }) { .map((user) => [user!.username, { avatarUrl: user!.avatarUrl }]) ); + const allThoughts = feedData.thoughts; + const { topLevelThoughts, repliesByParentId } = + buildThoughtThreads(allThoughts); + return (
@@ -39,22 +45,22 @@ async function FeedPage({ token }: { token: string }) {

Your Feed

- {feedData.thoughts.map((thought) => ( - - ))} - {feedData.thoughts.length === 0 && ( -

- Your feed is empty. Follow some users to see their thoughts here! -

- )} +
+ {topLevelThoughts.map((thought) => ( + + ))} + {topLevelThoughts.length === 0 && ( +

+ Your feed is empty. Follow some users to see their thoughts here! +

+ )} +