fix(frontend): initialize follow state from server-side following list on remote actor profile

This commit is contained in:
2026-05-15 10:54:01 +02:00
parent cf78b3e28f
commit 4b20bfd369
2 changed files with 17 additions and 4 deletions

View File

@@ -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 <RemoteUserProfile actor={actor} initialPosts={posts} me={me} />;
return (
<RemoteUserProfile
actor={actor}
initialPosts={posts}
me={me}
initialFollowed={initialFollowed}
/>
);
}