diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx index 3d0d88fa..08fa53ab 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx @@ -95,10 +95,7 @@ export const MentionsDrawerContent = (props: { }); // Sort by engagement: likes count 1, replies and quotes count 1.5 - const byEngagement = ( - a: { uri: string }, - b: { uri: string }, - ) => { + const byEngagement = (a: { uri: string }, b: { uri: string }) => { const scoreA = engagementScore(postViewMap.get(a.uri)); const scoreB = engagementScore(postViewMap.get(b.uri)); return scoreB - scoreA; @@ -354,6 +351,7 @@ function extractQuotedListItems( parentPath: number[], ): PubLeafletBlocksUnorderedList.ListItem[] { const result: PubLeafletBlocksUnorderedList.ListItem[] = []; + if (!Array.isArray(items)) return []; items.forEach((item, index) => { const itemPath = [...parentPath, index]; @@ -448,26 +446,28 @@ function trimTextBlock( PubLeafletBlocksText.isMain(block.block) || PubLeafletBlocksHeader.isMain(block.block) ) { - adjustedFacets = block.block?.facets - ?.map((facet) => { - const facetStart = facet.index.byteStart; - const facetEnd = facet.index.byteEnd; - - // Skip facets outside the quoted range - if (facetEnd <= startOffset || facetStart >= endOffset) { - return null; - } - - // Adjust facet indices - return { - ...facet, - index: { - byteStart: Math.max(0, facetStart - startOffset), - byteEnd: Math.min(quotedText.length, facetEnd - startOffset), - }, - }; - }) - .filter((f) => f !== null) as typeof block.block.facets; + adjustedFacets = !Array.isArray(block.block?.facets) + ? [] + : (block.block?.facets + ?.map((facet) => { + const facetStart = facet.index.byteStart; + const facetEnd = facet.index.byteEnd; + + // Skip facets outside the quoted range + if (facetEnd <= startOffset || facetStart >= endOffset) { + return null; + } + + // Adjust facet indices + return { + ...facet, + index: { + byteStart: Math.max(0, facetStart - startOffset), + byteEnd: Math.min(quotedText.length, facetEnd - startOffset), + }, + }; + }) + .filter((f) => f !== null) as typeof block.block.facets); } return {