Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_validate: Fetch subscribers before unsubscribed group mention warning.
Evy Kassirer91703ece016f
diff --git a/web/src/compose_validate.ts b/web/src/compose_validate.tsindex 93f1b31d431..fe8fbe85ccb 100644--- a/web/src/compose_validate.ts+++ b/web/src/compose_validate.ts@@ -352,11 +352,11 @@ export async function warn_if_mentioning_unsubscribed_user(}}-export function warn_if_mentioning_unsubscribed_group(+export async function warn_if_mentioning_unsubscribed_group(mentioned_group: UserGroup,$textarea: JQuery<HTMLTextAreaElement>,is_silent: boolean,-): void {+): Promise<void> {if (is_silent) {return;}@@ -370,7 +370,7 @@ export function warn_if_mentioning_unsubscribed_group(let any_member_subscribed = false;for (const user_id of group_members) {if (- stream_data.is_user_subscribed(stream_id, user_id) &&+ (await stream_data.maybe_fetch_is_user_subscribed(stream_id, user_id, false)) &&people.is_person_active(user_id)) {any_member_subscribed = true;@@ -381,6 +381,12 @@ export function warn_if_mentioning_unsubscribed_group(return;}+ // Double check that we're still composing to the same stream id+ // after the awaited fetches for subscriber data.+ if (get_stream_id_for_textarea($textarea) !== stream_id) {+ return;+ }+const $banner_container = compose_banner.get_compose_banner_container($textarea);// Check if a banner for this specific group already existsdiff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.tsindex 6ee6e10307d..ea7d943315f 100644--- a/web/src/composebox_typeahead.ts+++ b/web/src/composebox_typeahead.ts@@ -1192,7 +1192,7 @@ export function content_typeahead_selected(let user_group_mention_text = is_silent ? "@_*" : "@*";user_group_mention_text += item.name + "* ";beginning += user_group_mention_text;- compose_validate.warn_if_mentioning_unsubscribed_group(+ void compose_validate.warn_if_mentioning_unsubscribed_group(item,$textbox,is_silent ?? false,