From d095bbd256b908444fb38284d086e3b7b82db45b Mon Sep 17 00:00:00 2001 From: Ido Shamun <1993245+idoshamun@users.noreply.github.com> Date: Wed, 15 Apr 2026 09:48:27 +0300 Subject: [PATCH] fix: show shared post TLDR for share-type highlights When a highlight refers to a share post, the TLDR was empty because we only fetched summary/contentHtml from the main post. Now we also fetch sharedPost data and prefer it for share-type posts. --- .../src/components/highlights/HighlightItem.spec.tsx | 1 + .../src/components/highlights/HighlightItem.tsx | 12 +++++++++--- packages/shared/src/graphql/highlights.ts | 10 ++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/shared/src/components/highlights/HighlightItem.spec.tsx b/packages/shared/src/components/highlights/HighlightItem.spec.tsx index c641a65b9e..5f1e186989 100644 --- a/packages/shared/src/components/highlights/HighlightItem.spec.tsx +++ b/packages/shared/src/components/highlights/HighlightItem.spec.tsx @@ -13,6 +13,7 @@ const highlight: PostHighlightFeed = { highlightedAt: '2026-04-05T09:00:00.000Z', post: { id: 'post-1', + type: 'article', commentsPermalink: '/posts/post-1', summary, }, diff --git a/packages/shared/src/components/highlights/HighlightItem.tsx b/packages/shared/src/components/highlights/HighlightItem.tsx index ff6a3766e7..f708c53d18 100644 --- a/packages/shared/src/components/highlights/HighlightItem.tsx +++ b/packages/shared/src/components/highlights/HighlightItem.tsx @@ -3,6 +3,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'; import classNames from 'classnames'; import type { PostHighlightFeed } from '../../graphql/highlights'; import { stripHtmlTags } from '../../lib/strings'; +import { PostType } from '../../graphql/posts'; import { ArrowIcon } from '../icons/Arrow'; import { IconSize } from '../Icon'; import Link from '../utilities/Link'; @@ -33,18 +34,23 @@ export const HighlightItem = ({ }, [defaultExpanded]); const tldr = useMemo(() => { - const summary = highlight.post.summary?.trim(); + const post = + highlight.post.type === PostType.Share && highlight.post.sharedPost + ? highlight.post.sharedPost + : highlight.post; + + const summary = post.summary?.trim(); if (summary) { return summary; } - const html = highlight.post.contentHtml?.trim(); + const html = post.contentHtml?.trim(); if (html) { return stripHtmlTags(html).slice(0, 300); } return ''; - }, [highlight.post.summary, highlight.post.contentHtml]); + }, [highlight.post]); return (
diff --git a/packages/shared/src/graphql/highlights.ts b/packages/shared/src/graphql/highlights.ts index ef9af38994..e9d18575c8 100644 --- a/packages/shared/src/graphql/highlights.ts +++ b/packages/shared/src/graphql/highlights.ts @@ -20,9 +20,14 @@ export interface PostHighlightFeed { highlightedAt: string; post: { id: string; + type: string; commentsPermalink: string; summary?: string; contentHtml?: string; + sharedPost?: { + summary?: string; + contentHtml?: string; + }; }; } @@ -106,9 +111,14 @@ export const POST_HIGHLIGHT_FEED_FRAGMENT = gql` highlightedAt post { id + type commentsPermalink summary contentHtml + sharedPost { + summary + contentHtml + } } } `;