mirror of https://github.com/zulip/zulip.git
narrow: Replace pm_string() with _id and _email variants.
This makes the format returned by these functions more clear.
This commit is contained in:
parent
6e8523015c
commit
e039bdd1e1
|
@ -276,24 +276,24 @@ test("stream_sub", () => {
|
|||
assert.equal(narrow_state.stream(), undefined);
|
||||
});
|
||||
|
||||
test("pm_string", () => {
|
||||
test("pm_ids_string", () => {
|
||||
// This function will return undefined unless we're clearly
|
||||
// narrowed to a specific PM (including huddles) with real
|
||||
// users.
|
||||
narrow_state.set_current_filter(undefined);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
assert.equal(narrow_state.pm_ids_string(), undefined);
|
||||
|
||||
set_filter([
|
||||
["stream", "Foo"],
|
||||
["topic", "Bar"],
|
||||
]);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
assert.equal(narrow_state.pm_ids_string(), undefined);
|
||||
|
||||
set_filter([["pm-with", ""]]);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
assert.equal(narrow_state.pm_ids_string(), undefined);
|
||||
|
||||
set_filter([["pm-with", "bogus@foo.com"]]);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
assert.equal(narrow_state.pm_ids_string(), undefined);
|
||||
|
||||
const alice = {
|
||||
email: "alice@foo.com",
|
||||
|
@ -311,5 +311,5 @@ test("pm_string", () => {
|
|||
people.add_active_user(bob);
|
||||
|
||||
set_filter([["pm-with", "bob@foo.com,alice@foo.com"]]);
|
||||
assert.equal(narrow_state.pm_string(), "444,555");
|
||||
assert.equal(narrow_state.pm_ids_string(), "444,555");
|
||||
});
|
||||
|
|
|
@ -19,13 +19,13 @@ export function get_recipient_label(message) {
|
|||
stream: narrow_state.stream(),
|
||||
topic: narrow_state.topic(),
|
||||
};
|
||||
} else if (narrow_state.pm_string()) {
|
||||
} else if (narrow_state.pm_ids_string()) {
|
||||
// TODO: This is a total hack. Ideally, we'd rework
|
||||
// this to not duplicate the actual compose_actions.js
|
||||
// logic for what happens when you click the button,
|
||||
// and not call into random modules with hacky fake
|
||||
// "message" objects.
|
||||
const user_ids = people.user_ids_string_to_ids_array(narrow_state.pm_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}));
|
||||
message = {
|
||||
display_reply_to: message_store.get_pm_full_names({
|
||||
|
|
|
@ -860,7 +860,7 @@ export function narrow_to_next_topic() {
|
|||
}
|
||||
|
||||
export function narrow_to_next_pm_string() {
|
||||
const curr_pm = narrow_state.pm_string();
|
||||
const curr_pm = narrow_state.pm_ids_string();
|
||||
|
||||
const next_pm = topic_generator.get_next_unread_pm_string(curr_pm);
|
||||
|
||||
|
|
|
@ -140,10 +140,21 @@ export function topic() {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
export function pm_string() {
|
||||
export function pm_ids_string() {
|
||||
// If you are narrowed to a PM conversation
|
||||
// with users 4, 5, and 99, this will return "4,5,99"
|
||||
const emails_string = pm_emails_string();
|
||||
|
||||
if (!emails_string) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const user_ids_string = people.reply_to_to_user_ids_string(emails_string);
|
||||
|
||||
return user_ids_string;
|
||||
}
|
||||
|
||||
export function pm_emails_string() {
|
||||
if (current_filter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -153,15 +164,7 @@ export function pm_string() {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const emails_string = operands[0];
|
||||
|
||||
if (!emails_string) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const user_ids_string = people.reply_to_to_user_ids_string(emails_string);
|
||||
|
||||
return user_ids_string;
|
||||
return operands[0];
|
||||
}
|
||||
|
||||
export function get_first_unread_info() {
|
||||
|
@ -240,7 +243,7 @@ export function _possible_unread_message_ids() {
|
|||
}
|
||||
|
||||
if (current_filter.can_bucket_by("pm-with")) {
|
||||
current_filter_pm_string = pm_string();
|
||||
current_filter_pm_string = pm_ids_string();
|
||||
if (current_filter_pm_string === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue