Skip to content
Open
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
7 changes: 4 additions & 3 deletions mobile/components/CommentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ export default function CommentItem({
const parts: ReactNode[] = [];
let lastIndex = 0;
let match;
let key = 0;

while ((match = mentionRegex.exec(content)) !== null) {
if (match.index > lastIndex) {
parts.push(content.slice(lastIndex, match.index));
parts.push(<Text key={key++}>{content.slice(lastIndex, match.index)}</Text>);
}
const [, displayName, userId] = match;
parts.push(
Expand All @@ -152,10 +153,10 @@ export default function CommentItem({
}

if (lastIndex < content.length) {
parts.push(content.slice(lastIndex));
parts.push(<Text key={key++}>{content.slice(lastIndex)}</Text>);
}

return parts.length > 0 ? parts : content;
return parts.length > 0 ? <Text>{parts}</Text> : <Text>{content}</Text>;
};

return (
Expand Down