optimize mention highlighting

This commit is contained in:
Phillip Thelen
2019-02-06 15:00:41 +01:00
parent 8618913a75
commit 82863bd947
3 changed files with 2 additions and 10 deletions

View File

@@ -186,13 +186,6 @@
}
this.newMessage = innerText;
},
getTierIcon (member) {
const isNPC = Boolean(member.backer && member.backer.npc);
if (isNPC) {
return this.icons.tierNPC;
}
return this.icons[`tier${member.contributor.level}`];
},
},
beforeRouteUpdate (to, from, next) {
// Reset chat

View File

@@ -178,7 +178,7 @@ api.postChat = {
throw new NotAuthorized(res.t('messageGroupChatSpam'));
}
const message = await highlightMentions(req.body.message);
const [message, mentions] = await highlightMentions(req.body.message);
let client = req.headers['x-client'] || '3rd Party';
if (client) {
client = client.replace('habitica-', '');
@@ -203,7 +203,6 @@ api.postChat = {
headers: req.headers,
};
const mentions = req.body.message.match(mentionRegex);
if (mentions) {
analyticsObject.mentionsCount = mentions.length;
} else {

View File

@@ -18,5 +18,5 @@ export async function highlightMentions (text) {
text = text.replace(new RegExp(`@${username}(?![\\-\\w])`, 'g'), `[@${username}](/profile/${member._id})`);
});
}
return text;
return [text, mentions];
}