mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
optimize mention highlighting
This commit is contained in:
@@ -186,13 +186,6 @@
|
|||||||
}
|
}
|
||||||
this.newMessage = innerText;
|
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) {
|
beforeRouteUpdate (to, from, next) {
|
||||||
// Reset chat
|
// Reset chat
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ api.postChat = {
|
|||||||
throw new NotAuthorized(res.t('messageGroupChatSpam'));
|
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';
|
let client = req.headers['x-client'] || '3rd Party';
|
||||||
if (client) {
|
if (client) {
|
||||||
client = client.replace('habitica-', '');
|
client = client.replace('habitica-', '');
|
||||||
@@ -203,7 +203,6 @@ api.postChat = {
|
|||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mentions = req.body.message.match(mentionRegex);
|
|
||||||
if (mentions) {
|
if (mentions) {
|
||||||
analyticsObject.mentionsCount = mentions.length;
|
analyticsObject.mentionsCount = mentions.length;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ export async function highlightMentions (text) {
|
|||||||
text = text.replace(new RegExp(`@${username}(?![\\-\\w])`, 'g'), `[@${username}](/profile/${member._id})`);
|
text = text.replace(new RegExp(`@${username}(?![\\-\\w])`, 'g'), `[@${username}](/profile/${member._id})`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return text;
|
return [text, mentions];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user