diff options
author | Hailey <153161762+haileyok@users.noreply.github.com> | 2024-01-19 16:15:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-19 16:15:07 -0800 |
commit | eb07b983bd70cb9e913bb40a2ac0686a33fc3f6d (patch) | |
tree | bc2923a9b2e2d941daa843b3414a1ee3bbd427cd /src/view/com/util/text | |
parent | 920d48849e0c9d71443f72abab3ff650e264793e (diff) | |
download | voidsky-eb07b983bd70cb9e913bb40a2ac0686a33fc3f6d.tar.zst |
properly shorten links in quote embeds (#2570)
* properly shorten links in quote embeds * lint
Diffstat (limited to 'src/view/com/util/text')
-rw-r--r-- | src/view/com/util/text/RichText.tsx | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/view/com/util/text/RichText.tsx b/src/view/com/util/text/RichText.tsx index 99062e848..da473d929 100644 --- a/src/view/com/util/text/RichText.tsx +++ b/src/view/com/util/text/RichText.tsx @@ -17,6 +17,7 @@ export function RichText({ lineHeight = 1.2, style, numberOfLines, + noLinks, }: { testID?: string type?: TypographyVariant @@ -24,6 +25,7 @@ export function RichText({ lineHeight?: number style?: StyleProp<TextStyle> numberOfLines?: number + noLinks?: boolean }) { const theme = useTheme() const pal = usePalette('default') @@ -70,7 +72,11 @@ export function RichText({ for (const segment of richText.segments()) { const link = segment.link const mention = segment.mention - if (mention && AppBskyRichtextFacet.validateMention(mention).success) { + if ( + !noLinks && + mention && + AppBskyRichtextFacet.validateMention(mention).success + ) { els.push( <TextLink key={key} @@ -82,17 +88,21 @@ export function RichText({ />, ) } else if (link && AppBskyRichtextFacet.validateLink(link).success) { - els.push( - <TextLink - key={key} - type={type} - text={toShortUrl(segment.text)} - href={link.uri} - style={[style, lineHeightStyle, pal.link, {pointerEvents: 'auto'}]} - dataSet={WORD_WRAP} - warnOnMismatchingLabel - />, - ) + if (noLinks) { + els.push(toShortUrl(segment.text)) + } else { + els.push( + <TextLink + key={key} + type={type} + text={toShortUrl(segment.text)} + href={link.uri} + style={[style, lineHeightStyle, pal.link, {pointerEvents: 'auto'}]} + dataSet={WORD_WRAP} + warnOnMismatchingLabel + />, + ) + } } else { els.push(segment.text) } |