Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: render channel links in threads list #8205

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions app/components/remove_markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ import {type StyleProp, Text, type TextStyle} from 'react-native';
import Emoji from '@components/emoji';
import {computeTextStyle} from '@utils/markdown';

import ChannelMention from '../markdown/channel_mention';

import AtMention from './at_mention';

import type {MarkdownBaseRenderer, MarkdownEmojiRenderer, MarkdownTextStyles} from '@typings/global/markdown';
import type {MarkdownBaseRenderer, MarkdownChannelMentionRenderer, MarkdownEmojiRenderer, MarkdownTextStyles} from '@typings/global/markdown';

type Props = {
enableEmoji?: boolean;
enableCodeSpan?: boolean;
enableHardBreak?: boolean;
enableSoftBreak?: boolean;
enableChannelLink?: boolean;
baseStyle?: StyleProp<TextStyle>;
textStyle?: MarkdownTextStyles;
value: string;
};

const RemoveMarkdown = ({enableEmoji, enableHardBreak, enableSoftBreak, enableCodeSpan, baseStyle, textStyle = {}, value}: Props) => {
const RemoveMarkdown = ({enableEmoji, enableChannelLink, enableHardBreak, enableSoftBreak, enableCodeSpan, baseStyle, textStyle = {}, value}: Props) => {
const renderEmoji = useCallback(({emojiName, literal}: MarkdownEmojiRenderer) => {
if (!enableEmoji) {
return renderText({literal});
Expand Down Expand Up @@ -56,6 +59,16 @@ const RemoveMarkdown = ({enableEmoji, enableHardBreak, enableSoftBreak, enableCo
);
};

const renderChannelLink = ({context, channelName}: MarkdownChannelMentionRenderer) => {
return (
<ChannelMention
linkStyle={textStyle.link}
textStyle={computeTextStyle(textStyle, [], context)}
channelName={channelName}
/>
);
};

const renderCodeSpan = useCallback(({context, literal}: MarkdownBaseRenderer) => {
if (!enableCodeSpan) {
return renderText({literal});
Expand Down Expand Up @@ -88,7 +101,7 @@ const RemoveMarkdown = ({enableEmoji, enableHardBreak, enableSoftBreak, enableCo
link: Renderer.forwardChildren,
image: renderNull,
atMention: renderAtMention,
channelLink: Renderer.forwardChildren,
channelLink: enableChannelLink ? renderChannelLink : Renderer.forwardChildren,
emoji: renderEmoji,
hashtag: Renderer.forwardChildren,
latexinline: Renderer.forwardChildren,
Expand Down
1 change: 1 addition & 0 deletions app/screens/global_threads/threads_list/thread/thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const Thread = ({author, channel, location, post, teammateNameDisplay, testID, t
<RemoveMarkdown
enableCodeSpan={true}
enableEmoji={true}
enableChannelLink={true}
enableHardBreak={true}
enableSoftBreak={true}
textStyle={textStyles}
Expand Down
Loading