a tool for shared writing and social publishing

fix facet issue on quotes page

+22 -22
+22 -22
app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx
··· 95 95 }); 96 96 97 97 // Sort by engagement: likes count 1, replies and quotes count 1.5 98 - const byEngagement = ( 99 - a: { uri: string }, 100 - b: { uri: string }, 101 - ) => { 98 + const byEngagement = (a: { uri: string }, b: { uri: string }) => { 102 99 const scoreA = engagementScore(postViewMap.get(a.uri)); 103 100 const scoreB = engagementScore(postViewMap.get(b.uri)); 104 101 return scoreB - scoreA; ··· 354 351 parentPath: number[], 355 352 ): PubLeafletBlocksUnorderedList.ListItem[] { 356 353 const result: PubLeafletBlocksUnorderedList.ListItem[] = []; 354 + if (!Array.isArray(items)) return []; 357 355 358 356 items.forEach((item, index) => { 359 357 const itemPath = [...parentPath, index]; ··· 448 446 PubLeafletBlocksText.isMain(block.block) || 449 447 PubLeafletBlocksHeader.isMain(block.block) 450 448 ) { 451 - adjustedFacets = block.block?.facets 452 - ?.map((facet) => { 453 - const facetStart = facet.index.byteStart; 454 - const facetEnd = facet.index.byteEnd; 449 + adjustedFacets = !Array.isArray(block.block?.facets) 450 + ? [] 451 + : (block.block?.facets 452 + ?.map((facet) => { 453 + const facetStart = facet.index.byteStart; 454 + const facetEnd = facet.index.byteEnd; 455 455 456 - // Skip facets outside the quoted range 457 - if (facetEnd <= startOffset || facetStart >= endOffset) { 458 - return null; 459 - } 456 + // Skip facets outside the quoted range 457 + if (facetEnd <= startOffset || facetStart >= endOffset) { 458 + return null; 459 + } 460 460 461 - // Adjust facet indices 462 - return { 463 - ...facet, 464 - index: { 465 - byteStart: Math.max(0, facetStart - startOffset), 466 - byteEnd: Math.min(quotedText.length, facetEnd - startOffset), 467 - }, 468 - }; 469 - }) 470 - .filter((f) => f !== null) as typeof block.block.facets; 461 + // Adjust facet indices 462 + return { 463 + ...facet, 464 + index: { 465 + byteStart: Math.max(0, facetStart - startOffset), 466 + byteEnd: Math.min(quotedText.length, facetEnd - startOffset), 467 + }, 468 + }; 469 + }) 470 + .filter((f) => f !== null) as typeof block.block.facets); 471 471 } 472 472 473 473 return {