From 346430fab58bdb2e18b1d0f1d8adbdd5383773df Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Fri, 6 Mar 2026 16:27:42 -0500 Subject: [PATCH] fix bug with object facets Not sure where this data originated from, need to track it down still --- actions/publishToPublication.ts | 6 +++--- app/lish/[did]/[publication]/[rkey]/Blocks/TextBlock.tsx | 2 +- .../[did]/[publication]/[rkey]/Blocks/TextBlockCore.tsx | 2 +- .../[publication]/[rkey]/Footnotes/PublishedFootnotes.tsx | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/actions/publishToPublication.ts b/actions/publishToPublication.ts index fe2988dd..ec1a0730 100644 --- a/actions/publishToPublication.ts +++ b/actions/publishToPublication.ts @@ -564,7 +564,7 @@ async function processBlocksToPages( $type: "pub.leaflet.blocks.header", level: Math.floor(headingLevel?.data.value || 1), plaintext: stringValue, - facets, + ...(facets.length > 0 && { facets }), }; return block; } @@ -574,7 +574,7 @@ async function processBlocksToPages( let block: $Typed = { $type: ids.PubLeafletBlocksBlockquote, plaintext: stringValue, - facets, + ...(facets.length > 0 && { facets }), }; return block; } @@ -585,7 +585,7 @@ async function processBlocksToPages( let block: $Typed = { $type: ids.PubLeafletBlocksText, plaintext: stringValue, - facets, + ...(facets.length > 0 && { facets }), ...(textSize && { textSize: textSize.data.value }), }; return block; diff --git a/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlock.tsx b/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlock.tsx index 3f3196b5..8dbd577e 100644 --- a/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlock.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlock.tsx @@ -18,7 +18,7 @@ export function TextBlock(props: { let highlights = useHighlight(props.index, props.pageId); let facets = useMemo(() => { if (props.preview) return props.facets; - let facets = [...(props.facets || [])]; + let facets = [...(Array.isArray(props.facets) ? props.facets : [])]; for (let highlight of highlights) { const fragmentId = props.pageId ? `${props.pageId}~${props.index.join(".")}_${highlight.startOffset || 0}` diff --git a/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlockCore.tsx b/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlockCore.tsx index 0fb82af3..292d44c7 100644 --- a/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlockCore.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Blocks/TextBlockCore.tsx @@ -154,7 +154,7 @@ export class RichText { constructor(props: { text: string; facets: Facet[] }) { this.unicodeText = new UnicodeString(props.text); - this.facets = props.facets; + this.facets = Array.isArray(props.facets) ? props.facets : undefined; if (this.facets) { this.facets = this.facets .filter((facet) => facet.index.byteStart <= facet.index.byteEnd) diff --git a/app/lish/[did]/[publication]/[rkey]/Footnotes/PublishedFootnotes.tsx b/app/lish/[did]/[publication]/[rkey]/Footnotes/PublishedFootnotes.tsx index 62dcf464..deeec557 100644 --- a/app/lish/[did]/[publication]/[rkey]/Footnotes/PublishedFootnotes.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Footnotes/PublishedFootnotes.tsx @@ -28,7 +28,8 @@ export function collectFootnotesFromBlocks( let idx = 1; function scanFacets(facets?: PubLeafletRichtextFacet.Main[]) { - if (!facets) return; + if (!facets || !Array.isArray(facets)) return; + console.log(facets); for (let facet of facets) { for (let feature of facet.features) { if (PubLeafletRichtextFacet.isFootnote(feature)) { @@ -86,9 +87,7 @@ export function PublishedFootnoteSection(props: { ); } -export function PublishedFootnoteItem(props: { - footnote: PublishedFootnote; -}) { +export function PublishedFootnoteItem(props: { footnote: PublishedFootnote }) { let fn = props.footnote; return (