diff --git a/web/src/compose_actions.js b/web/src/compose_actions.js index 66ad0e9325..daa8c99e70 100644 --- a/web/src/compose_actions.js +++ b/web/src/compose_actions.js @@ -403,7 +403,7 @@ export function on_topic_narrow() { return; } - if (compose_state.stream_name() !== narrow_state.stream()) { + if (compose_state.stream_name() !== narrow_state.stream_name()) { // If we changed streams, then we only leave the // compose box open if there is content or if the recipient was edited. if (compose_state.has_message_content() || compose_state.is_recipient_edited_manually()) { diff --git a/web/src/compose_closed_ui.js b/web/src/compose_closed_ui.js index f3f3873ea5..e46d4d23a9 100644 --- a/web/src/compose_closed_ui.js +++ b/web/src/compose_closed_ui.js @@ -20,7 +20,7 @@ export function get_recipient_label(message) { // we label the button as replying to the thread. if (narrow_state.narrowed_to_topic()) { message = { - stream: narrow_state.stream(), + stream: narrow_state.stream_name(), topic: narrow_state.topic(), }; } else if (narrow_state.pm_ids_string()) { diff --git a/web/src/compose_recipient.js b/web/src/compose_recipient.js index fc90a740bb..66e9ec92ac 100644 --- a/web/src/compose_recipient.js +++ b/web/src/compose_recipient.js @@ -36,7 +36,7 @@ export function set_selected_recipient_id(recipient_id) { function composing_to_current_topic_narrow() { return ( - util.lower_same(compose_state.stream_name(), narrow_state.stream() || "") && + util.lower_same(compose_state.stream_name(), narrow_state.stream_name() || "") && util.lower_same(compose_state.topic(), narrow_state.topic() || "") ); } diff --git a/web/src/drafts.js b/web/src/drafts.js index 91abbd326a..6006ed8ce4 100644 --- a/web/src/drafts.js +++ b/web/src/drafts.js @@ -451,7 +451,7 @@ function current_recipient_data() { // Prioritize recipients from the compose box first. If the compose // box isn't open, just return data from the current narrow. if (!compose_state.composing()) { - const stream_name = narrow_state.stream(); + const stream_name = narrow_state.stream_name(); return { stream_name, topic: narrow_state.topic(), diff --git a/web/src/message_list.js b/web/src/message_list.js index a6902fbdf9..1d1795ed4c 100644 --- a/web/src/message_list.js +++ b/web/src/message_list.js @@ -326,7 +326,7 @@ export class MessageList { if (!this.narrowed) { return; } - const stream_name = narrow_state.stream(); + const stream_name = narrow_state.stream_name(); if (stream_name === undefined) { return; } diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index 8926943918..f672c64da1 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -927,7 +927,7 @@ export class MessageListView { last_message_group.message_containers.at(-1).msg.historical; } - const stream_name = narrow_state.stream(); + const stream_name = narrow_state.stream_name(); if (stream_name !== undefined) { // If user narrows to a stream, doesn't update // trailing bookend if user is subscribed. diff --git a/web/src/narrow.js b/web/src/narrow.js index 6efd8fb8d1..ffa35ad865 100644 --- a/web/src/narrow.js +++ b/web/src/narrow.js @@ -801,7 +801,7 @@ export function activate_stream_for_cycle_hotkey(stream_name) { } export function stream_cycle_backward() { - const curr_stream = narrow_state.stream(); + const curr_stream = narrow_state.stream_name(); if (!curr_stream) { return; @@ -817,7 +817,7 @@ export function stream_cycle_backward() { } export function stream_cycle_forward() { - const curr_stream = narrow_state.stream(); + const curr_stream = narrow_state.stream_name(); if (!curr_stream) { return; @@ -834,7 +834,7 @@ export function stream_cycle_forward() { export function narrow_to_next_topic(opts = {}) { const curr_info = { - stream: narrow_state.stream(), + stream: narrow_state.stream_name(), topic: narrow_state.topic(), }; diff --git a/web/src/narrow_banner.js b/web/src/narrow_banner.js index 6ed379a300..bba027bf48 100644 --- a/web/src/narrow_banner.js +++ b/web/src/narrow_banner.js @@ -243,7 +243,7 @@ function pick_empty_narrow_banner() { } function can_toggle_narrowed_stream() { - const stream_name = narrow_state.stream(); + const stream_name = narrow_state.stream_name(); if (!stream_name) { return false; diff --git a/web/src/narrow_state.js b/web/src/narrow_state.js index acb481f815..965077d629 100644 --- a/web/src/narrow_state.js +++ b/web/src/narrow_state.js @@ -110,7 +110,7 @@ export function set_compose_defaults() { return opts; } -export function stream() { +export function stream_name() { if (current_filter === undefined) { return undefined; } diff --git a/web/src/search_suggestion.js b/web/src/search_suggestion.js index a4261250b1..0abd25635e 100644 --- a/web/src/search_suggestion.js +++ b/web/src/search_suggestion.js @@ -401,7 +401,7 @@ function get_topic_suggestions(last, operators) { if (filter.has_operator("stream")) { stream = filter.operands("stream")[0]; } else { - stream = narrow_state.stream(); + stream = narrow_state.stream_name(); suggest_operators.push({operator: "stream", operand: stream}); } break; diff --git a/web/tests/example3.test.js b/web/tests/example3.test.js index 8febbef88a..7b95f8c892 100644 --- a/web/tests/example3.test.js +++ b/web/tests/example3.test.js @@ -79,7 +79,7 @@ run_test("narrow_state", () => { // As we often do, first make assertions about the starting // state: - assert.equal(narrow_state.stream(), undefined); + assert.equal(narrow_state.stream_name(), undefined); // Now set up a Filter object. const filter_terms = [ @@ -92,6 +92,6 @@ run_test("narrow_state", () => { // And here is where we actually change state. narrow_state.set_current_filter(filter); - assert.equal(narrow_state.stream(), "Denmark"); + assert.equal(narrow_state.stream_name(), "Denmark"); assert.equal(narrow_state.topic(), "copenhagen"); }); diff --git a/web/tests/message_list.test.js b/web/tests/message_list.test.js index fbf7b925c8..9c61ad16aa 100644 --- a/web/tests/message_list.test.js +++ b/web/tests/message_list.test.js @@ -332,7 +332,7 @@ run_test("bookend", ({override}) => { list.view.clear_trailing_bookend = noop; list.narrowed = true; - override(narrow_state, "stream", () => "IceCream"); + override(narrow_state, "stream_name", () => "IceCream"); let is_subscribed = true; let invite_only = false; diff --git a/web/tests/narrow_state.test.js b/web/tests/narrow_state.test.js index 12b62920bb..73de4ea50c 100644 --- a/web/tests/narrow_state.test.js +++ b/web/tests/narrow_state.test.js @@ -42,7 +42,7 @@ test("stream", () => { ]); assert.ok(narrow_state.active()); - assert.equal(narrow_state.stream(), "Test"); + assert.equal(narrow_state.stream_name(), "Test"); assert.equal(narrow_state.stream_sub().stream_id, test_stream.stream_id); assert.equal(narrow_state.topic(), "Bar"); assert.ok(narrow_state.is_for_stream_id(test_stream.stream_id)); @@ -268,14 +268,14 @@ test("topic", () => { test("stream_sub", () => { set_filter([]); - assert.equal(narrow_state.stream(), undefined); + assert.equal(narrow_state.stream_name(), undefined); assert.equal(narrow_state.stream_sub(), undefined); set_filter([ ["stream", "Foo"], ["topic", "Bar"], ]); - assert.equal(narrow_state.stream(), "Foo"); + assert.equal(narrow_state.stream_name(), "Foo"); assert.equal(narrow_state.stream_sub(), undefined); const sub = {name: "Foo", stream_id: 55}; @@ -286,7 +286,7 @@ test("stream_sub", () => { ["sender", "someone"], ["topic", "random"], ]); - assert.equal(narrow_state.stream(), undefined); + assert.equal(narrow_state.stream_name(), undefined); }); test("pm_ids_string", () => { diff --git a/web/tests/search_suggestion.test.js b/web/tests/search_suggestion.test.js index 05daa5cf2e..44d28c5b2a 100644 --- a/web/tests/search_suggestion.test.js +++ b/web/tests/search_suggestion.test.js @@ -82,7 +82,7 @@ function test(label, f) { test("basic_get_suggestions", ({override}) => { const query = "fred"; - override(narrow_state, "stream", () => "office"); + override(narrow_state, "stream_name", () => "office"); const suggestions = get_suggestions(query); @@ -240,7 +240,7 @@ test("dm_suggestions", ({override, mock_template}) => { // "pm-with" operator returns search result // and "dm" operator as a suggestions - override(narrow_state, "stream", () => undefined); + override(narrow_state, "stream_name", () => undefined); query = "pm-with"; suggestions = get_suggestions(query); expected = ["pm-with", "dm:"]; @@ -460,7 +460,7 @@ test("has_suggestions", ({override, mock_template}) => { let query = "h"; stream_data.add_sub({stream_id: 44, name: "devel", subscribed: true}); stream_data.add_sub({stream_id: 77, name: "office", subscribed: true}); - override(narrow_state, "stream", () => {}); + override(narrow_state, "stream_name", () => {}); let suggestions = get_suggestions(query); let expected = ["h", "has:link", "has:image", "has:attachment"]; @@ -519,7 +519,7 @@ test("check_is_suggestions", ({override, mock_template}) => { stream_data.add_sub({stream_id: 44, name: "devel", subscribed: true}); stream_data.add_sub({stream_id: 77, name: "office", subscribed: true}); - override(narrow_state, "stream", () => {}); + override(narrow_state, "stream_name", () => {}); let query = "i"; let suggestions = get_suggestions(query); @@ -600,7 +600,7 @@ test("check_is_suggestions", ({override, mock_template}) => { test("sent_by_me_suggestions", ({override, mock_template}) => { mock_template("search_description.hbs", true, (_data, html) => html); - override(narrow_state, "stream", () => {}); + override(narrow_state, "stream_name", () => {}); let query = ""; let suggestions = get_suggestions(query); @@ -678,7 +678,7 @@ test("topic_suggestions", ({override, mock_template}) => { override(stream_topic_history_util, "get_server_history", () => {}); stream_data.add_sub({stream_id: 77, name: "office", subscribed: true}); - override(narrow_state, "stream", () => "office"); + override(narrow_state, "stream_name", () => "office"); const devel_id = 44; const office_id = 77; @@ -817,7 +817,7 @@ test("stream_completion", ({override, mock_template}) => { stream_data.add_sub({stream_id: 77, name: "office", subscribed: true}); stream_data.add_sub({stream_id: 88, name: "dev help", subscribed: true}); - override(narrow_state, "stream", () => {}); + override(narrow_state, "stream_name", () => {}); let query = "stream:of"; let suggestions = get_suggestions(query); @@ -840,7 +840,7 @@ test("people_suggestions", ({override, mock_template}) => { let query = "te"; - override(narrow_state, "stream", () => {}); + override(narrow_state, "stream_name", () => {}); const ted = { email: "ted@zulip.com", @@ -942,7 +942,7 @@ test("people_suggestions", ({override, mock_template}) => { test("operator_suggestions", ({override, mock_template}) => { mock_template("search_description.hbs", true, (_data, html) => html); - override(narrow_state, "stream", () => undefined); + override(narrow_state, "stream_name", () => undefined); // Completed operator should return nothing let query = "stream:";