From 28c13f6d0ee9b10e822652db101bd6a5d159036a Mon Sep 17 00:00:00 2001 From: evykassirer Date: Wed, 8 May 2024 22:50:33 -0700 Subject: [PATCH] message_store: Modify get_pm_full_names to only take user ids. This will let us properly call it from compose_closed_ui without a full message object, which we need to convert it to typescript. --- web/src/compose_closed_ui.js | 6 +----- web/src/message_helper.js | 4 +++- web/src/message_list_view.js | 4 +++- web/src/message_store.ts | 4 ++-- web/src/people.ts | 2 +- web/tests/message_store.test.js | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/web/src/compose_closed_ui.js b/web/src/compose_closed_ui.js index f28d046dff..47d59899f9 100644 --- a/web/src/compose_closed_ui.js +++ b/web/src/compose_closed_ui.js @@ -38,11 +38,7 @@ export function get_recipient_label(message) { return format_stream_recipient_label(stream_id, topic); } else if (narrow_state.pm_ids_string()) { const user_ids = people.user_ids_string_to_ids_array(narrow_state.pm_ids_string()); - const user_ids_dicts = user_ids.map((user_id) => ({id: user_id})); - return message_store.get_pm_full_names({ - type: "private", - display_recipient: user_ids_dicts, - }); + return message_store.get_pm_full_names(user_ids); } } else { message = message_lists.current.selected_message(); diff --git a/web/src/message_helper.js b/web/src/message_helper.js index 7c6626bd91..d25fe99827 100644 --- a/web/src/message_helper.js +++ b/web/src/message_helper.js @@ -58,7 +58,9 @@ export function process_new_message(message) { case "private": message.is_private = true; message.reply_to = util.normalize_recipients(message_store.get_pm_emails(message)); - message.display_reply_to = message_store.get_pm_full_names(message); + message.display_reply_to = message_store.get_pm_full_names( + people.pm_with_user_ids(message), + ); message.pm_with_url = people.pm_with_url(message); message.to_user_ids = people.pm_reply_user_string(message); diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index 5141a26834..4440d490c0 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -243,7 +243,9 @@ function populate_group_from_message_container(group, message_container) { } else if (group.is_private) { group.pm_with_url = message_container.pm_with_url; group.recipient_users = get_users_for_recipient_row(message_container.msg); - group.display_reply_to_for_tooltip = message_store.get_pm_full_names(message_container.msg); + group.display_reply_to_for_tooltip = message_store.get_pm_full_names( + people.pm_with_user_ids(message_container.msg), + ); } group.display_recipient = message_container.msg.display_recipient; group.topic_links = message_container.msg.topic_links; diff --git a/web/src/message_store.ts b/web/src/message_store.ts index 3f0e092c51..4924c4aa21 100644 --- a/web/src/message_store.ts +++ b/web/src/message_store.ts @@ -184,8 +184,8 @@ export function get_pm_emails(message: Message): string { return emails.join(", "); } -export function get_pm_full_names(message: Message): string { - const user_ids = people.pm_with_user_ids(message) ?? []; +export function get_pm_full_names(user_ids: number[]): string { + user_ids = people.sorted_other_user_ids(user_ids); const names = people.get_display_full_names(user_ids).sort(); return names.join(", "); diff --git a/web/src/people.ts b/web/src/people.ts index 31087d44ac..828f1e7e7b 100644 --- a/web/src/people.ts +++ b/web/src/people.ts @@ -513,7 +513,7 @@ export function pm_reply_to(message: Message): string | undefined { return reply_to; } -function sorted_other_user_ids(user_ids: number[]): number[] { +export function sorted_other_user_ids(user_ids: number[]): number[] { // This excludes your own user id unless you're the only user // (i.e. you sent a message to yourself). diff --git a/web/tests/message_store.test.js b/web/tests/message_store.test.js index e816cf40bc..2ea485b6f7 100644 --- a/web/tests/message_store.test.js +++ b/web/tests/message_store.test.js @@ -226,7 +226,7 @@ test("errors", ({disallow_rewire}) => { assert.throws( () => { - message_store.get_pm_full_names(message); + message_store.get_pm_full_names(people.pm_with_user_ids(message)); }, { name: "Error",