From 00fab06c992eadb8a10c0feff6d5cce6b4de865d Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Mon, 20 Oct 2025 15:20:22 -0400 Subject: [PATCH] fix actually posting comments on subpages --- .../[rkey]/Interactions/Comments/CommentBox.tsx | 2 ++ .../[rkey]/Interactions/Comments/commentAction.ts | 2 ++ .../[publication]/[rkey]/Interactions/Comments/index.tsx | 9 ++++++++- .../[publication]/[rkey]/Interactions/Interactions.tsx | 4 ++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentBox.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentBox.tsx index 2ddd8456..98b9e940 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentBox.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentBox.tsx @@ -39,6 +39,7 @@ import { betterIsUrl } from "src/utils/isURL"; export function CommentBox(props: { doc_uri: string; + pageId?: string; replyTo?: string; onSubmit?: () => void; autoFocus?: boolean; @@ -56,6 +57,7 @@ export function CommentBox(props: { let currentState = view.current.state; let [plaintext, facets] = docToFacetedText(currentState.doc); let comment = await publishComment({ + pageId: props.pageId, document: props.doc_uri, comment: { plaintext, diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts index f0b28d7c..bd1234a3 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts @@ -11,6 +11,7 @@ import { Json } from "supabase/database.types"; export async function publishComment(args: { document: string; + pageId?: string; comment: { plaintext: string; facets: PubLeafletRichtextFacet.Main[]; @@ -28,6 +29,7 @@ export async function publishComment(args: { ); let record: Un$Typed = { subject: args.document, + onPage: args.pageId, createdAt: new Date().toISOString(), plaintext: args.comment.plaintext, facets: args.comment.facets, diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx index 9efc7a35..f94fce28 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx @@ -40,6 +40,7 @@ export function Comments(props: { }, [props.comments, localComments]); let pathname = usePathname(); let redirectRoute = useMemo(() => { + if (typeof window === "undefined") return; let url = new URL(pathname, window.location.origin); url.searchParams.set("refreshAuth", ""); url.searchParams.set("interactionDrawer", "comments"); @@ -61,7 +62,7 @@ export function Comments(props: { {identity?.atp_did ? ( - + ) : (
Connect a Bluesky account to comment @@ -88,6 +89,7 @@ export function Comments(props: { ?.record as AppBskyActorProfile.Record; return ( { return (
@@ -139,6 +142,7 @@ const Comment = (props: { /> { let { identity } = useIdentityData(); @@ -200,6 +205,7 @@ const Replies = (props: {
{replyBoxOpen && ( { return ( { - if (!drawerOpen || drawer !== "comments") + if (!drawerOpen || drawer !== "comments" || pageId !== props.pageId) openInteractionDrawer("comments", document_uri, props.pageId); else setInteractionState(document_uri, { drawerOpen: false }); }} -- 2.51.2