Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

people: Deduplicate get_full_names logic.

Abhijeet Prasad Bodas421cf05176c2
diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js
index 9fcdd0f1b01..3096684ef0e 100644
--- a/frontend_tests/node_tests/people.js
+++ b/frontend_tests/node_tests/people.js
@@ -401,9 +401,9 @@ test_people("get_recipients", () => {
assert.equal(people.get_recipients("30,32"), "Isaac Newton");
});
-test_people("safe_full_names", () => {
+test_people("get_full_names_for_poll_option", () => {
people.add_active_user(isaac);
- const names = people.safe_full_names([me.user_id, isaac.user_id]);
+ const names = people.get_full_names_for_poll_option([me.user_id, isaac.user_id]);
assert.equal(names, "Me Myself, Isaac Newton");
});
diff --git a/frontend_tests/node_tests/poll_widget.js b/frontend_tests/node_tests/poll_widget.js
index e43c525d777..249df0661a5 100644
--- a/frontend_tests/node_tests/poll_widget.js
+++ b/frontend_tests/node_tests/poll_widget.js
@@ -39,7 +39,7 @@ run_test("PollData my question", () => {
is_my_poll,
question,
options: [],
- comma_separated_names: people.safe_full_names,
+ comma_separated_names: people.get_full_names_for_poll_option,
report_error_function: blueslip.warn,
});
diff --git a/static/js/people.js b/static/js/people.js
index 34db7a32750..d355ccec3de 100644
--- a/static/js/people.js
+++ b/static/js/people.js
@@ -298,15 +298,8 @@ export function email_list_to_user_ids_string(emails) {
return user_ids.join(",");
}
-export function safe_full_names(user_ids) {
- let names = user_ids.map((user_id) => {
- const person = people_by_user_id_dict.get(user_id);
- return person && person.full_name;
- });
-
- names = names.filter(Boolean);
-
- return names.join(", ");
+export function get_full_names_for_poll_option(user_ids) {
+ return get_display_full_names(user_ids).join(", ");
}
export function get_display_full_names(user_ids) {
diff --git a/static/js/poll_widget.js b/static/js/poll_widget.js
index 8f5cc4d9a53..b7005c8b339 100644
--- a/static/js/poll_widget.js
+++ b/static/js/poll_widget.js
@@ -19,7 +19,7 @@ export function activate({
is_my_poll,
question,
options,
- comma_separated_names: people.safe_full_names,
+ comma_separated_names: people.get_full_names_for_poll_option,
report_error_function: blueslip.warn,
});