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