Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
people: Add helper function to get people for dm suggestion.
Pratik Chanda8b938c8e0f0f
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.tsindex fb51a6e4d06..6e34092fbbe 100644--- a/web/src/composebox_typeahead.ts+++ b/web/src/composebox_typeahead.ts@@ -870,8 +870,13 @@ export function get_person_suggestions();};+ const message_persons = people.get_people_for_dm({+ exclude_non_welcome_bots,+ exclude_non_message_people: true,+ active_users_only: true,+ });const filtered_message_persons = filter_persons(- people.get_active_message_people(),+ message_persons,opts.filter_pills,opts.want_broadcast,filterer,@@ -882,21 +887,16 @@ export function get_person_suggestions(if (filtered_message_persons.length >= cutoff_length) {filtered_persons = filtered_message_persons;} else {- if (exclude_non_welcome_bots) {- filtered_persons = filter_persons(- people.get_realm_users_and_welcome_bot(),- opts.filter_pills,- opts.want_broadcast,- filterer,- );- } else {- filtered_persons = filter_persons(- people.get_realm_users_and_system_bots(),- opts.filter_pills,- opts.want_broadcast,- filterer,- );- }+ filtered_persons = filter_persons(+ people.get_people_for_dm({+ exclude_non_welcome_bots,+ exclude_non_message_people: false,+ active_users_only: false,+ }),+ opts.filter_pills,+ opts.want_broadcast,+ filterer,+ );}return typeahead_helper.sort_recipients({diff --git a/web/src/people.ts b/web/src/people.tsindex 16e4d3bd764..49dd0f48066 100644--- a/web/src/people.ts+++ b/web/src/people.ts@@ -1154,6 +1154,19 @@ export function get_active_message_people(): User[] {return active_message_people;}+export function get_people_for_dm(opts: {+ exclude_non_welcome_bots: boolean;+ exclude_non_message_people: boolean;+ active_users_only: boolean;+}): User[] {+ if (opts.exclude_non_message_people) {+ return opts.active_users_only ? get_active_message_people() : get_message_people();+ } else if (opts.exclude_non_welcome_bots) {+ return get_realm_users_and_welcome_bot();+ }+ return get_realm_users_and_system_bots();+}+export function get_people_for_search_bar(query: string): User[] {const pred = build_person_matcher(query);