Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_state: Use stream_name() and topic() universally.
evykassirer53d8abe79b66
diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.jsindex 798e56bb0b8..1b44c3f435a 100644--- a/frontend_tests/node_tests/compose.js+++ b/frontend_tests/node_tests/compose.js@@ -731,7 +731,7 @@ test_ui("on_events", ({override}) => {});test_ui("create_message_object", ({override, override_rewire}) => {- $("#stream_message_recipient_stream").val("social");+ compose_state.set_stream_name("social");$("#stream_message_recipient_topic").val("lunch");$("#compose-textarea").val("burrito");@@ -744,7 +744,7 @@ test_ui("create_message_object", ({override, override_rewire}) => {blueslip.expect("error", "Trying to send message with bad stream name: BOGUS STREAM");- $("#stream_message_recipient_stream").val("BOGUS STREAM");+ compose_state.set_stream_name("BOGUS STREAM");message = compose.create_message_object();assert.equal(message.to, "BOGUS STREAM");assert.equal(message.topic, "lunch");diff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.jsindex 7c4fe59f8e4..44e62b07cfe 100644--- a/frontend_tests/node_tests/compose_actions.js+++ b/frontend_tests/node_tests/compose_actions.js@@ -131,8 +131,8 @@ test("start", ({override, override_rewire}) => {assert_visible("#stream-message");assert_hidden("#private-message");- assert.equal($("#stream_message_recipient_stream").val(), "stream1");- assert.equal($("#stream_message_recipient_topic").val(), "topic1");+ assert.equal(compose_state.stream_name(), "stream1");+ assert.equal(compose_state.topic(), "topic1");assert.equal(compose_state.get_message_type(), "stream");assert.ok(compose_state.composing());@@ -151,8 +151,8 @@ test("start", ({override, override_rewire}) => {opts = {};start("stream", opts);- assert.equal($("#stream_message_recipient_stream").val(), "Denmark");- assert.equal($("#stream_message_recipient_topic").val(), "");+ assert.equal(compose_state.stream_name(), "Denmark");+ assert.equal(compose_state.topic(), "");compose_defaults = {trigger: "compose_hotkey",@@ -160,8 +160,8 @@ test("start", ({override, override_rewire}) => {opts = {};start("stream", opts);- assert.equal($("#stream_message_recipient_stream").val(), "Denmark");- assert.equal($("#stream_message_recipient_topic").val(), "");+ assert.equal(compose_state.stream_name(), "Denmark");+ assert.equal(compose_state.topic(), "");const social = {subscribed: true,@@ -174,8 +174,8 @@ test("start", ({override, override_rewire}) => {// More than 1 subscription, do not autofillopts = {};start("stream", opts);- assert.equal($("#stream_message_recipient_stream").val(), "");- assert.equal($("#stream_message_recipient_topic").val(), "");+ assert.equal(compose_state.stream_name(), "");+ assert.equal(compose_state.topic(), "");stream_data.clear_subscriptions();// Start PM@@ -268,7 +268,7 @@ test("respond_to_message", ({override, override_rewire}) => {opts = {};respond_to_message(opts);- assert.equal($("#stream_message_recipient_stream").val(), "devel");+ assert.equal(compose_state.stream_name(), "devel");});test("reply_with_mention", ({override, override_rewire}) => {@@ -296,7 +296,7 @@ test("reply_with_mention", ({override, override_rewire}) => {const opts = {};reply_with_mention(opts);- assert.equal($("#stream_message_recipient_stream").val(), "devel");+ assert.equal(compose_state.stream_name(), "devel");assert.equal(syntax_to_insert, "@**Bob Roberts**");// Test for extended mention syntax@@ -314,7 +314,7 @@ test("reply_with_mention", ({override, override_rewire}) => {people.add_active_user(bob_2);reply_with_mention(opts);- assert.equal($("#stream_message_recipient_stream").val(), "devel");+ assert.equal(compose_state.stream_name(), "devel");assert.equal(syntax_to_insert, "@**Bob Roberts|40**");});diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.jsindex 2aa159e6555..9902fdebb35 100644--- a/frontend_tests/node_tests/composebox_typeahead.js+++ b/frontend_tests/node_tests/composebox_typeahead.js@@ -735,7 +735,7 @@ test("initialize", ({override, mock_template}) => {return topics;};- $("#stream_message_recipient_stream").val("Sweden");+ compose_state.set_stream_name("Sweden");let actual_value = options.source();// Topics should be sorted alphabetically, not by addition order.let expected_value = topics;@@ -792,7 +792,7 @@ test("initialize", ({override, mock_template}) => {topic_typeahead_called = true;// Unset the stream name.- $("#stream_message_recipient_stream").val("");+ compose_state.set_stream_name("");};let pm_recipient_typeahead_called = false;diff --git a/static/js/compose_actions.js b/static/js/compose_actions.jsindex 0c1bada851c..c8563805334 100644--- a/static/js/compose_actions.js+++ b/static/js/compose_actions.js@@ -268,8 +268,8 @@ export function update_placeholder_text() {const opts = {message_type: compose_state.get_message_type(),- stream: $("#stream_message_recipient_stream").val(),- topic: $("#stream_message_recipient_topic").val(),+ stream: compose_state.stream_name(),+ topic: compose_state.topic(),private_message_recipient: compose_pm_pill.get_emails(),};diff --git a/static/js/compose_fade.js b/static/js/compose_fade.jsindex 6c796ed8074..de08bd6df0e 100644--- a/static/js/compose_fade.js+++ b/static/js/compose_fade.js@@ -27,8 +27,8 @@ export function set_focused_recipient(msg_type) {};if (focused_recipient.type === "stream") {- const stream_name = $("#stream_message_recipient_stream").val();- focused_recipient.topic = $("#stream_message_recipient_topic").val();+ const stream_name = compose_state.stream_name();+ focused_recipient.topic = compose_state.topic();focused_recipient.stream = stream_name;const sub = stream_data.get_sub(stream_name);if (sub) {