From c92d05e204d0c5180ccaeb74fc669f2601d223c9 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 24 Jun 2024 18:51:06 -0500 Subject: [PATCH] Detect without resolution, disable links --- src/components/FeedCard.tsx | 48 +++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/src/components/FeedCard.tsx b/src/components/FeedCard.tsx index 47896d4f72..4a0261a156 100644 --- a/src/components/FeedCard.tsx +++ b/src/components/FeedCard.tsx @@ -5,6 +5,7 @@ import { AppBskyFeedDefs, AppBskyGraphDefs, AtUri, + RichText as RichTextApi, } from '@atproto/api' import {msg, plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -24,7 +25,6 @@ import * as Toast from 'view/com/util/Toast' import {useTheme} from '#/alf' import {atoms as a} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' -import {useRichText} from '#/components/hooks/useRichText' import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash' import {Link as InternalLink, LinkProps} from '#/components/Link' @@ -33,21 +33,18 @@ import * as Prompt from '#/components/Prompt' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' -type CommonProps = { - disableDescriptionFacets?: boolean -} type Props = - | ({ + | { type: 'feed' view: AppBskyFeedDefs.GeneratorView - } & CommonProps) - | ({ + } + | { type: 'list' view: AppBskyGraphDefs.ListView - } & CommonProps) + } export function Default(props: Props) { - const {type, view, disableDescriptionFacets} = props + const {type, view} = props const displayName = type === 'feed' ? view.displayName : view.name const purpose = type === 'list' ? view.purpose : undefined return ( @@ -63,10 +60,7 @@ export function Default(props: Props) { /> - + {type === 'feed' && } @@ -204,25 +198,15 @@ export function TitleAndBylinePlaceholder({creator}: {creator?: boolean}) { ) } -export function Description({ - description, - disableFacets, -}: { - description?: string - disableFacets?: boolean -}) { - if (!description) return null - return disableFacets ? ( - - ) : ( - - ) -} - -export function DescriptionWithFacets({description}: {description?: string}) { - const [rt] = useRichText(description || '') - if (!description) return null - return +export function Description({description}: {description?: string}) { + const [rt] = React.useState(() => { + if (!description) return + const rt = new RichTextApi({text: description || ''}) + rt.detectFacetsWithoutResolution() + return rt + }) + if (!rt) return null + return } export function Likes({count}: {count: number}) {