fix: pass tags and users

This commit is contained in:
Alejandro Gomez 2023-01-14 15:17:17 +01:00
parent d6ab2c8f16
commit af53773f06
No known key found for this signature in database
GPG Key ID: 4DF39E566658C817
1 changed files with 3 additions and 3 deletions

View File

@ -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);