Use shouldLinkifyMessage in MessageBody/ReadMore

This commit is contained in:
Scott Nonnenberg 2023-08-16 16:06:40 -07:00 committed by Jamie Kyle
parent 8b0da36caa
commit 7969dd881e
2 changed files with 7 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import React from 'react';
import type { Props as MessageBodyPropsType } from './MessageBody';
import { MessageBody } from './MessageBody';
import { graphemeAndLinkAwareSlice } from '../../util/graphemeAndLinkAwareSlice';
import { shouldLinkifyMessage } from '../../types/LinkPreview';
export type Props = Pick<
MessageBodyPropsType,
@ -52,6 +53,7 @@ export function MessageBodyReadMore({
}: Props): JSX.Element {
const maxLength = displayLimit || INITIAL_LENGTH;
const shouldDisableLinks = disableLinks || !shouldLinkifyMessage(text);
const { hasReadMore, text: slicedText } = graphemeAndLinkAwareSlice(
text,
maxLength,
@ -71,7 +73,7 @@ export function MessageBodyReadMore({
bodyRanges={bodyRanges}
direction={direction}
disableJumbomoji={disableJumbomoji}
disableLinks={disableLinks}
disableLinks={shouldDisableLinks}
i18n={i18n}
isSpoilerExpanded={isSpoilerExpanded}
kickOffBodyDownload={kickOffBodyDownload}