diff --git a/thoughts-frontend/app/remote-actor/page.tsx b/thoughts-frontend/app/remote-actor/page.tsx index d725a43..0b7464d 100644 --- a/thoughts-frontend/app/remote-actor/page.tsx +++ b/thoughts-frontend/app/remote-actor/page.tsx @@ -1,7 +1,7 @@ import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { cookies } from "next/headers"; -import { getMe, lookupRemoteActor, getRemoteActorPosts, Me } from "@/lib/api"; +import { getMe, getRemoteFollowing, lookupRemoteActor, getRemoteActorPosts, Me } from "@/lib/api"; import { RemoteUserProfile } from "@/components/remote-user-profile"; interface RemoteActorPageProps { @@ -53,10 +53,11 @@ export default async function RemoteActorPage({ const token = (await cookies()).get("auth_token")?.value ?? null; - const [actorResult, postsResult, meResult] = await Promise.allSettled([ + const [actorResult, postsResult, meResult, followingResult] = await Promise.allSettled([ lookupRemoteActor(handle, token), getRemoteActorPosts(handle, 1, token), token ? getMe(token) : Promise.resolve(null), + token ? getRemoteFollowing(token) : Promise.resolve([]), ]); if (actorResult.status === "rejected") { @@ -68,6 +69,16 @@ export default async function RemoteActorPage({ postsResult.status === "fulfilled" ? postsResult.value.items : []; const me = meResult.status === "fulfilled" ? (meResult.value as Me | null) : null; + const following = + followingResult.status === "fulfilled" ? followingResult.value : []; + const initialFollowed = following.some((f) => f.url === actor.url); - return ; + return ( + + ); } diff --git a/thoughts-frontend/components/remote-user-profile.tsx b/thoughts-frontend/components/remote-user-profile.tsx index 1a48e7b..9777925 100644 --- a/thoughts-frontend/components/remote-user-profile.tsx +++ b/thoughts-frontend/components/remote-user-profile.tsx @@ -17,14 +17,16 @@ interface RemoteUserProfileProps { actor: RemoteActor; initialPosts: Thought[]; me: Me | null; + initialFollowed?: boolean; } export function RemoteUserProfile({ actor, initialPosts, me, + initialFollowed = false, }: RemoteUserProfileProps) { - const [followed, setFollowed] = useState(false); + const [followed, setFollowed] = useState(initialFollowed); const [loading, setLoading] = useState(false); const { token } = useAuth();