Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Replace pm_string() with _id and _email variants.
evykassirere039bdd1e1f6
diff --git a/frontend_tests/node_tests/narrow_state.js b/frontend_tests/node_tests/narrow_state.jsindex 7e6d5659cc3..6d0fe0e74c6 100644--- a/frontend_tests/node_tests/narrow_state.js+++ b/frontend_tests/node_tests/narrow_state.js@@ -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", "[email protected]"]]);- assert.equal(narrow_state.pm_string(), undefined);+ assert.equal(narrow_state.pm_ids_string(), undefined);const alice = {email: "[email protected]",@@ -311,5 +311,5 @@ test("pm_string", () => {people.add_active_user(bob);set_filter([["pm-with", "[email protected],[email protected]"]]);- assert.equal(narrow_state.pm_string(), "444,555");+ assert.equal(narrow_state.pm_ids_string(), "444,555");});diff --git a/static/js/compose_closed_ui.js b/static/js/compose_closed_ui.jsindex 8a3584cabd7..7ed0e4b7044 100644--- a/static/js/compose_closed_ui.js+++ b/static/js/compose_closed_ui.js@@ -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({diff --git a/static/js/narrow.js b/static/js/narrow.jsindex 6885958c0dc..9c371cb1fe0 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -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);diff --git a/static/js/narrow_state.js b/static/js/narrow_state.jsindex d6739991974..3063157b87f 100644--- a/static/js/narrow_state.js+++ b/static/js/narrow_state.js@@ -140,28 +140,31 @@ 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 (current_filter === undefined) {+ if (!emails_string) {return undefined;}- const operands = current_filter.operands("pm-with");- if (operands.length !== 1) {- return undefined;- }+ const user_ids_string = people.reply_to_to_user_ids_string(emails_string);- const emails_string = operands[0];+ return user_ids_string;+}- if (!emails_string) {+export function pm_emails_string() {+ if (current_filter === undefined) {return undefined;}- const user_ids_string = people.reply_to_to_user_ids_string(emails_string);+ const operands = current_filter.operands("pm-with");+ if (operands.length !== 1) {+ return undefined;+ }- 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 [];}