From af53773f06a71e602adeb9f2c7fe73c603790068 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Sat, 14 Jan 2023 15:17:17 +0100 Subject: [PATCH] fix: pass tags and users --- src/Text.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Text.js b/src/Text.js index 77fb7b2b6..9e7eb0a95 100644 --- a/src/Text.js +++ b/src/Text.js @@ -78,14 +78,14 @@ function extractLinks(fragments) { }).flat(); } -export function extractMentions(fragments, tags = [], users = {}) { +export function extractMentions(fragments, tags, users) { return fragments.map(f => { if (typeof f === "string") { return f.split(MentionRegex).map((match) => { let matchTag = match.match(/#\[(\d+)\]/); if (matchTag && matchTag.length === 2) { let idx = parseInt(matchTag[1]); - let ref = tags.find(a => a.Index === idx); + let ref = tags?.find(a => a.Index === idx); if (ref) { switch (ref.Key) { case "p": { @@ -152,7 +152,7 @@ function transformParagraph({ body, tags, users }) { } function transformText({ body, tags, users }) { - let fragments = extractMentions(body); + let fragments = extractMentions(body, tags, users); fragments = extractLinks(fragments); fragments = extractInvoices(fragments); fragments = extractHashtags(fragments);