Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
minor: Refactor `userMentionHandler` to avoid duplicating escaping logic.
akshatdalton13421a19695a
diff --git a/static/js/markdown.js b/static/js/markdown.jsindex 2882fe3de8a..912eabddfeb 100644--- a/static/js/markdown.js+++ b/static/js/markdown.js@@ -165,21 +165,24 @@ export function apply_markdown(message) {// flags on the message itself that get used by the message// view code and possibly our filtering code.- if (helpers.my_user_id() === user_id && !silently) {- message.mentioned = true;- message.mentioned_me_directly = true;- }- let str = "";+ // If I mention "@aLiCe sMITH", I still want "Alice Smith" to+ // show in the pill.+ let display_text = helpers.get_actual_name_from_user_id(user_id);+ let classes;if (silently) {- str += `<span class="user-mention silent" data-user-id="${_.escape(user_id)}">`;+ classes = "user-mention silent";} else {- str += `<span class="user-mention" data-user-id="${_.escape(user_id)}">@`;+ if (helpers.my_user_id() === user_id) {+ message.mentioned = true;+ message.mentioned_me_directly = true;+ }+ classes = "user-mention";+ display_text = "@" + display_text;}- // If I mention "@aLiCe sMITH", I still want "Alice Smith" to- // show in the pill.- const actual_full_name = helpers.get_actual_name_from_user_id(user_id);- return `${str}${_.escape(actual_full_name)}</span>`;+ return `<span class="${classes}" data-user-id="${_.escape(user_id)}">${_.escape(+ display_text,+ )}</span>`;},groupMentionHandler(name) {const group = helpers.get_user_group_from_name(name);