properly shorten links in quote embeds (#2570)
* properly shorten links in quote embeds * lint
This commit is contained in:
parent
920d48849e
commit
eb07b983bd
3 changed files with 41 additions and 20 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue