a tool for shared writing and social publishing
0

Configure Feed

Select the types of activity you want to include in your feed.

simplify comment section logic

Jared Pereira (May 27, 2026, 6:28 PM EDT) 011cc5a4 af2cbe71

+12 -30
+9 -21
app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentsSection.tsx
··· 1 1 import { supabaseServerClient } from "supabase/serverClient"; 2 - import { AtUri } from "@atproto/syntax"; 3 2 import { getProfiles } from "src/identity"; 4 3 import { CommentsDrawerContent, type Comment } from "./index"; 4 + import { AtUri } from "@atproto/syntax"; 5 5 6 6 export async function CommentsSection({ 7 7 document_uri, ··· 10 10 }) { 11 11 const { data: rows } = await supabaseServerClient 12 12 .from("comments_on_documents") 13 - .select("uri, record") 13 + .select("uri, record ") 14 14 .eq("document", document_uri); 15 15 16 - const safeRows = rows ?? []; 17 - const dids = Array.from(new Set(safeRows.map((c) => new AtUri(c.uri).host))); 18 - const profiles = await getProfiles(dids); 16 + const dids = (rows ?? []).map((c) => new AtUri(c.uri).host); 17 + const profiles = await getProfiles([...new Set(dids)]); 19 18 20 - const comments: Comment[] = safeRows.map((c) => { 21 - const did = new AtUri(c.uri).host; 22 - const p = profiles.get(did); 23 - return { 24 - uri: c.uri, 25 - record: c.record, 26 - profile: p 27 - ? { 28 - did: p.did, 29 - handle: p.handle, 30 - displayName: p.displayName, 31 - avatar: p.avatar, 32 - } 33 - : null, 34 - }; 35 - }); 19 + const comments: Comment[] = (rows ?? []).map((c) => ({ 20 + uri: c.uri, 21 + record: c.record, 22 + profile: profiles.get(new AtUri(c.uri).host) ?? null, 23 + })); 36 24 37 25 return ( 38 26 <CommentsDrawerContent document_uri={document_uri} comments={comments} />
+3 -9
app/(app)/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx
··· 16 16 import { useLocalizedDate } from "src/hooks/useLocalizedDate"; 17 17 import { ProfilePopover } from "components/ProfilePopover"; 18 18 import { LoginModal } from "components/LoginButton"; 19 - 20 - export type CommentProfile = { 21 - did: string; 22 - handle: string | null; 23 - displayName: string | null; 24 - avatar: string | null; 25 - }; 19 + import { type Profile } from "src/identity"; 26 20 27 21 export type Comment = { 28 22 record: Json; 29 23 uri: string; 30 - profile: CommentProfile | null; 24 + profile: Profile | null; 31 25 }; 32 26 export function CommentsDrawerContent(props: { 33 27 document_uri: string; ··· 118 112 document: string; 119 113 comment: Comment; 120 114 comments: Comment[]; 121 - profile: CommentProfile | null; 115 + profile: Profile | null; 122 116 record: PubLeafletComment.Record; 123 117 pageId?: string; 124 118 }) => {