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.
This commit is contained in:
Pratik Chanda 2024-09-18 02:25:47 +05:30 committed by Tim Abbott
parent bc623369c3
commit 41cd04a071
1 changed files with 11 additions and 0 deletions

View File

@ -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);
}