a tool for shared writing and social publishing

count top level quotes and comments correctly

+37 -14
+7 -9
app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx
··· 23 23 (c) => (c.record as any)?.onPage === props.pageId, 24 24 ); 25 25 26 - const filteredQuotes = props.pageId 27 - ? props.quotes.filter((q) => q.link.includes(props.pageId!)) 28 - : props.quotes.filter((q) => { 29 - const url = new URL(q.link); 30 - const quoteParam = url.pathname.split("/l-quote/")[1]; 31 - if (!quoteParam) return null; 32 - const quotePosition = decodeQuotePosition(quoteParam); 33 - return !quotePosition?.pageId; 34 - }); 26 + const filteredQuotes = props.quotes.filter((q) => { 27 + const url = new URL(q.link); 28 + const quoteParam = url.pathname.split("/l-quote/")[1]; 29 + if (!quoteParam) return null; 30 + const quotePosition = decodeQuotePosition(quoteParam); 31 + return quotePosition?.pageId === props.pageId; 32 + }); 35 33 36 34 return ( 37 35 <>
+20 -3
app/lish/[did]/[publication]/[rkey]/PostHeader/PostHeader.tsx
··· 1 1 "use client"; 2 - import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api"; 2 + import { 3 + PubLeafletComment, 4 + PubLeafletDocument, 5 + PubLeafletPublication, 6 + } from "lexicons/api"; 3 7 import { getPublicationURL } from "app/lish/createPub/getPublicationURL"; 4 8 import { Interactions } from "../Interactions/Interactions"; 5 9 import { PostPageData } from "../getPostPageData"; ··· 7 11 import { useIdentityData } from "components/IdentityProvider"; 8 12 import { EditTiny } from "components/Icons/EditTiny"; 9 13 import { SpeedyLink } from "components/SpeedyLink"; 14 + import { decodeQuotePosition } from "../quotePosition"; 10 15 11 16 export function PostHeader(props: { 12 17 data: PostPageData; ··· 86 91 <Interactions 87 92 showComments={props.preferences.showComments} 88 93 compact 89 - quotesCount={document.document_mentions_in_bsky.length} 90 - commentsCount={document.comments_on_documents.length} 94 + quotesCount={ 95 + document.document_mentions_in_bsky.filter((q) => { 96 + const url = new URL(q.link); 97 + const quoteParam = url.pathname.split("/l-quote/")[1]; 98 + if (!quoteParam) return null; 99 + const quotePosition = decodeQuotePosition(quoteParam); 100 + return !quotePosition?.pageId; 101 + }).length 102 + } 103 + commentsCount={ 104 + document.comments_on_documents.filter( 105 + (c) => !(c.record as PubLeafletComment.Record)?.onPage, 106 + ).length 107 + } 91 108 /> 92 109 </div> 93 110 </div>
+10 -2
app/lish/[did]/[publication]/[rkey]/PostPages.tsx
··· 75 75 export const openPage = ( 76 76 parent: string | undefined, 77 77 page: string, 78 - options?: { scrollIntoView?: boolean } 78 + options?: { scrollIntoView?: boolean }, 79 79 ) => { 80 80 flushSync(() => { 81 81 usePostPageUIState.setState((state) => { ··· 158 158 /> 159 159 <Interactions 160 160 showComments={preferences.showComments} 161 - quotesCount={document.document_mentions_in_bsky.length} 161 + quotesCount={ 162 + document.document_mentions_in_bsky.filter((q) => { 163 + const url = new URL(q.link); 164 + const quoteParam = url.pathname.split("/l-quote/")[1]; 165 + if (!quoteParam) return null; 166 + const quotePosition = decodeQuotePosition(quoteParam); 167 + return !quotePosition?.pageId; 168 + }).length 169 + } 162 170 commentsCount={ 163 171 document.comments_on_documents.filter( 164 172 (c) => !(c.record as PubLeafletComment.Record)?.onPage,