From 41cd04a0717b96a836c7528df265ad4f09ca5859 Mon Sep 17 00:00:00 2001 From: Pratik Chanda Date: Wed, 18 Sep 2024 02:25:47 +0530 Subject: [PATCH] composebox_typeahead: Remove own user suggestion if recipients present. Earlier, in compose recipient, if user adds own user pill in recipient, DM message list would fade even though it was the correct view. This commit prevents user from adding own user pill in DM recipient if other recipients are already added. Fixes: zulip#31629. --- web/src/composebox_typeahead.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.ts index d13095ee4b..4d99a1ca1f 100644 --- a/web/src/composebox_typeahead.ts +++ b/web/src/composebox_typeahead.ts @@ -596,11 +596,22 @@ export function get_pm_people(query: string): (UserGroupPillData | UserPillData) filter_groups_for_guests: true, }; const suggestions = get_person_suggestions(query, opts); + const current_user_ids = compose_pm_pill.get_user_ids(); + const my_user_id = people.my_current_user_id(); // We know these aren't mentions because `want_broadcast` was `false`. // TODO: In the future we should separate user and mention so we don't have // to do this. const user_suggestions: (UserGroupPillData | UserPillData)[] = []; for (const suggestion of suggestions) { + if ( + suggestion.type === "user" && + suggestion.user.user_id === my_user_id && + current_user_ids.length > 0 + ) { + // We don't show current user in typeahead suggestion if recipient + // box already has a user pill to avoid fading conversation + continue; + } assert(suggestion.type !== "broadcast"); user_suggestions.push(suggestion); }