Skip to content

Commit

Permalink
fix: use set for mentions comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
petermiller310 committed Nov 21, 2023
1 parent d46a736 commit bf2fc2f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/Note/NoteMentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const NoteMentions: FC<NoteMentionsProps> = ({
}) => {
const { deleted, editing, text } = note;

const mentionStrings = mentionableUsers.map((user) => `@${user.value}`);
const mentionStrings = new Set(mentionableUsers.map((user) => `@${user.value}`));

const mentionStyles = () => (
<style jsx global>
Expand Down Expand Up @@ -109,8 +109,8 @@ const NoteMentions: FC<NoteMentionsProps> = ({
/>
<CardBody>
<CardText style={{ whiteSpace: 'pre-wrap' }}>
{text.split(/(\s+)/).map((word) =>
mentionStrings.includes(word) ? (
{text?.split(/(\s+)/).map((word) =>
mentionStrings.has(word) ? (
<span className="note__mention-info">
{word}
{mentionStyles()}
Expand Down

0 comments on commit bf2fc2f

Please sign in to comment.