a tool for shared writing and social publishing

render quote content from subpages

+13 -1
+13 -1
app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx
··· 19 19 import { useActiveHighlightState } from "../useHighlight"; 20 20 import { PostContent } from "../PostContent"; 21 21 import { ProfileViewBasic } from "@atproto/api/dist/client/types/app/bsky/actor/defs"; 22 + import { flushSync } from "react-dom"; 23 + import { openPage } from "../PostPages"; 22 24 23 25 export const Quotes = (props: { 24 26 quotes: { link: string; bsky_posts: { post_view: Json } | null }[]; ··· 90 92 const data = useContext(PostPageContext); 91 93 92 94 let record = data?.data as PubLeafletDocument.Record; 93 - let page = record.pages[0] as PubLeafletPagesLinearDocument.Main; 95 + let page: PubLeafletPagesLinearDocument.Main | undefined = ( 96 + props.position.pageId 97 + ? record.pages.find( 98 + (p) => 99 + (p as PubLeafletPagesLinearDocument.Main).id === 100 + props.position.pageId, 101 + ) 102 + : record.pages[0] 103 + ) as PubLeafletPagesLinearDocument.Main; 94 104 // Extract blocks within the quote range 95 105 const content = extractQuotedBlocks(page.blocks || [], props.position, []); 96 106 return ( ··· 106 116 <div 107 117 className="quoteSectionQuote text-secondary text-sm text-left hover:cursor-pointer" 108 118 onClick={(e) => { 119 + if (props.position.pageId) 120 + flushSync(() => openPage(undefined, props.position.pageId!)); 109 121 let scrollMargin = isMobile 110 122 ? 16 111 123 : e.currentTarget.getBoundingClientRect().top;