Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 31s
test / unit (pull_request) Failing after 11m18s
test / integration (pull_request) Failing after 18m1s
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import { cookies } from "next/headers";
|
|
import { getMe, lookupRemoteActor, getRemoteActorPosts, Me } from "@/lib/api";
|
|
import { RemoteUserProfile } from "@/components/remote-user-profile";
|
|
|
|
interface RemoteActorPageProps {
|
|
searchParams: Promise<{ handle?: string }>;
|
|
}
|
|
|
|
export default async function RemoteActorPage({
|
|
searchParams,
|
|
}: RemoteActorPageProps) {
|
|
const { handle } = await searchParams;
|
|
if (!handle) notFound();
|
|
|
|
const token = (await cookies()).get("auth_token")?.value ?? null;
|
|
|
|
const [actorResult, postsResult, meResult] = await Promise.allSettled([
|
|
lookupRemoteActor(handle, token),
|
|
getRemoteActorPosts(handle, 1, token),
|
|
token ? getMe(token) : Promise.resolve(null),
|
|
]);
|
|
|
|
if (actorResult.status === "rejected") {
|
|
notFound();
|
|
}
|
|
|
|
const actor = actorResult.value;
|
|
const posts =
|
|
postsResult.status === "fulfilled" ? postsResult.value.items : [];
|
|
const me =
|
|
meResult.status === "fulfilled" ? (meResult.value as Me | null) : null;
|
|
|
|
return <RemoteUserProfile actor={actor} initialPosts={posts} me={me} />;
|
|
}
|