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.
This commit is contained in:
evykassirer 2024-05-08 22:50:33 -07:00 committed by Tim Abbott
parent 8fb1c0683e
commit 28c13f6d0e
6 changed files with 11 additions and 11 deletions

View File

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

View File

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

View File

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

View File

@ -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(", ");

View File

@ -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).

View File

@ -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",