diff --git a/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentsSection.tsx b/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentsSection.tsx index b0912d14..9fdb7312 100644 --- a/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentsSection.tsx +++ b/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentsSection.tsx @@ -1,7 +1,7 @@ import { supabaseServerClient } from "supabase/serverClient"; -import { AtUri } from "@atproto/syntax"; import { getProfiles } from "src/identity"; import { CommentsDrawerContent, type Comment } from "./index"; +import { AtUri } from "@atproto/syntax"; export async function CommentsSection({ document_uri, @@ -10,29 +10,17 @@ export async function CommentsSection({ }) { const { data: rows } = await supabaseServerClient .from("comments_on_documents") - .select("uri, record") + .select("uri, record ") .eq("document", document_uri); - const safeRows = rows ?? []; - const dids = Array.from(new Set(safeRows.map((c) => new AtUri(c.uri).host))); - const profiles = await getProfiles(dids); + const dids = (rows ?? []).map((c) => new AtUri(c.uri).host); + const profiles = await getProfiles([...new Set(dids)]); - const comments: Comment[] = safeRows.map((c) => { - const did = new AtUri(c.uri).host; - const p = profiles.get(did); - return { - uri: c.uri, - record: c.record, - profile: p - ? { - did: p.did, - handle: p.handle, - displayName: p.displayName, - avatar: p.avatar, - } - : null, - }; - }); + const comments: Comment[] = (rows ?? []).map((c) => ({ + uri: c.uri, + record: c.record, + profile: profiles.get(new AtUri(c.uri).host) ?? null, + })); return ( diff --git a/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx b/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx index 2a6e9325..1549407b 100644 --- a/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx +++ b/app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx @@ -16,18 +16,12 @@ import { timeAgo } from "src/utils/timeAgo"; import { useLocalizedDate } from "src/hooks/useLocalizedDate"; import { ProfilePopover } from "components/ProfilePopover"; import { LoginModal } from "components/LoginButton"; - -export type CommentProfile = { - did: string; - handle: string | null; - displayName: string | null; - avatar: string | null; -}; +import { type Profile } from "src/identity"; export type Comment = { record: Json; uri: string; - profile: CommentProfile | null; + profile: Profile | null; }; export function CommentsDrawerContent(props: { document_uri: string; @@ -118,7 +112,7 @@ const Comment = (props: { document: string; comment: Comment; comments: Comment[]; - profile: CommentProfile | null; + profile: Profile | null; record: PubLeafletComment.Record; pageId?: string; }) => {