From f257ef2aad7292a5deec8bde0c78ce3a60caf7e9 Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Mon, 20 Oct 2025 16:16:29 -0400 Subject: [PATCH] count top level quotes and comments correctly --- .../[rkey]/Interactions/InteractionDrawer.tsx | 16 ++++++------- .../[rkey]/PostHeader/PostHeader.tsx | 23 ++++++++++++++++--- .../[did]/[publication]/[rkey]/PostPages.tsx | 12 ++++++++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx index 44b7d343..dee2361c 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx @@ -23,15 +23,13 @@ export const InteractionDrawer = (props: { (c) => (c.record as any)?.onPage === props.pageId, ); - const filteredQuotes = props.pageId - ? props.quotes.filter((q) => q.link.includes(props.pageId!)) - : props.quotes.filter((q) => { - const url = new URL(q.link); - const quoteParam = url.pathname.split("/l-quote/")[1]; - if (!quoteParam) return null; - const quotePosition = decodeQuotePosition(quoteParam); - return !quotePosition?.pageId; - }); + const filteredQuotes = props.quotes.filter((q) => { + const url = new URL(q.link); + const quoteParam = url.pathname.split("/l-quote/")[1]; + if (!quoteParam) return null; + const quotePosition = decodeQuotePosition(quoteParam); + return quotePosition?.pageId === props.pageId; + }); return ( <> diff --git a/app/lish/[did]/[publication]/[rkey]/PostHeader/PostHeader.tsx b/app/lish/[did]/[publication]/[rkey]/PostHeader/PostHeader.tsx index 052fb8cb..4a09c767 100644 --- a/app/lish/[did]/[publication]/[rkey]/PostHeader/PostHeader.tsx +++ b/app/lish/[did]/[publication]/[rkey]/PostHeader/PostHeader.tsx @@ -1,5 +1,9 @@ "use client"; -import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api"; +import { + PubLeafletComment, + PubLeafletDocument, + PubLeafletPublication, +} from "lexicons/api"; import { getPublicationURL } from "app/lish/createPub/getPublicationURL"; import { Interactions } from "../Interactions/Interactions"; import { PostPageData } from "../getPostPageData"; @@ -7,6 +11,7 @@ import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/act import { useIdentityData } from "components/IdentityProvider"; import { EditTiny } from "components/Icons/EditTiny"; import { SpeedyLink } from "components/SpeedyLink"; +import { decodeQuotePosition } from "../quotePosition"; export function PostHeader(props: { data: PostPageData; @@ -86,8 +91,20 @@ export function PostHeader(props: { { + const url = new URL(q.link); + const quoteParam = url.pathname.split("/l-quote/")[1]; + if (!quoteParam) return null; + const quotePosition = decodeQuotePosition(quoteParam); + return !quotePosition?.pageId; + }).length + } + commentsCount={ + document.comments_on_documents.filter( + (c) => !(c.record as PubLeafletComment.Record)?.onPage, + ).length + } /> diff --git a/app/lish/[did]/[publication]/[rkey]/PostPages.tsx b/app/lish/[did]/[publication]/[rkey]/PostPages.tsx index 18a57057..100fa35b 100644 --- a/app/lish/[did]/[publication]/[rkey]/PostPages.tsx +++ b/app/lish/[did]/[publication]/[rkey]/PostPages.tsx @@ -75,7 +75,7 @@ export const useInitializeOpenPages = () => { export const openPage = ( parent: string | undefined, page: string, - options?: { scrollIntoView?: boolean } + options?: { scrollIntoView?: boolean }, ) => { flushSync(() => { usePostPageUIState.setState((state) => { @@ -158,7 +158,15 @@ export function PostPages({ /> { + const url = new URL(q.link); + const quoteParam = url.pathname.split("/l-quote/")[1]; + if (!quoteParam) return null; + const quotePosition = decodeQuotePosition(quoteParam); + return !quotePosition?.pageId; + }).length + } commentsCount={ document.comments_on_documents.filter( (c) => !(c.record as PubLeafletComment.Record)?.onPage, -- 2.51.2