mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
optimize mention highlighting
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user