mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
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:
@@ -38,11 +38,7 @@ export function get_recipient_label(message) {
|
|||||||
return format_stream_recipient_label(stream_id, topic);
|
return format_stream_recipient_label(stream_id, topic);
|
||||||
} else if (narrow_state.pm_ids_string()) {
|
} 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 = 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(user_ids);
|
||||||
return message_store.get_pm_full_names({
|
|
||||||
type: "private",
|
|
||||||
display_recipient: user_ids_dicts,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message = message_lists.current.selected_message();
|
message = message_lists.current.selected_message();
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ export function process_new_message(message) {
|
|||||||
case "private":
|
case "private":
|
||||||
message.is_private = true;
|
message.is_private = true;
|
||||||
message.reply_to = util.normalize_recipients(message_store.get_pm_emails(message));
|
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.pm_with_url = people.pm_with_url(message);
|
||||||
message.to_user_ids = people.pm_reply_user_string(message);
|
message.to_user_ids = people.pm_reply_user_string(message);
|
||||||
|
|
||||||
|
|||||||
@@ -243,7 +243,9 @@ function populate_group_from_message_container(group, message_container) {
|
|||||||
} else if (group.is_private) {
|
} else if (group.is_private) {
|
||||||
group.pm_with_url = message_container.pm_with_url;
|
group.pm_with_url = message_container.pm_with_url;
|
||||||
group.recipient_users = get_users_for_recipient_row(message_container.msg);
|
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.display_recipient = message_container.msg.display_recipient;
|
||||||
group.topic_links = message_container.msg.topic_links;
|
group.topic_links = message_container.msg.topic_links;
|
||||||
|
|||||||
@@ -184,8 +184,8 @@ export function get_pm_emails(message: Message): string {
|
|||||||
return emails.join(", ");
|
return emails.join(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_pm_full_names(message: Message): string {
|
export function get_pm_full_names(user_ids: number[]): string {
|
||||||
const user_ids = people.pm_with_user_ids(message) ?? [];
|
user_ids = people.sorted_other_user_ids(user_ids);
|
||||||
const names = people.get_display_full_names(user_ids).sort();
|
const names = people.get_display_full_names(user_ids).sort();
|
||||||
|
|
||||||
return names.join(", ");
|
return names.join(", ");
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ export function pm_reply_to(message: Message): string | undefined {
|
|||||||
return reply_to;
|
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
|
// This excludes your own user id unless you're the only user
|
||||||
// (i.e. you sent a message to yourself).
|
// (i.e. you sent a message to yourself).
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ test("errors", ({disallow_rewire}) => {
|
|||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => {
|
() => {
|
||||||
message_store.get_pm_full_names(message);
|
message_store.get_pm_full_names(people.pm_with_user_ids(message));
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Error",
|
name: "Error",
|
||||||
|
|||||||
Reference in New Issue
Block a user