Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_id: Replace empty string with undefined.
evykassirer77fc836edf38
diff --git a/tools/test-js-with-node b/tools/test-js-with-nodeindex 456f5b4ca7c..a37364fd748 100755--- a/tools/test-js-with-node+++ b/tools/test-js-with-node@@ -218,7 +218,6 @@ EXEMPT_FILES = make_set("web/src/spectators.ts","web/src/spoilers.ts","web/src/starred_messages_ui.js",- "web/src/stream_bar.js","web/src/stream_color.js","web/src/stream_color_events.js","web/src/stream_create.js",diff --git a/web/src/compose.js b/web/src/compose.jsindex 7bf38a1b762..40939ba55a9 100644--- a/web/src/compose.js+++ b/web/src/compose.js@@ -68,7 +68,7 @@ export function create_message_object() {content: compose_state.message_content(),sender_id: page_params.user_id,queue_id: page_params.queue_id,- stream_id: "",+ stream_id: undefined,};message.topic = "";diff --git a/web/src/compose_actions.js b/web/src/compose_actions.jsindex 99c9cede5c4..ab7b31b0907 100644--- a/web/src/compose_actions.js+++ b/web/src/compose_actions.js@@ -111,10 +111,12 @@ export function complete_starting_tasks(msg_type, opts) {maybe_scroll_up_selected_message();compose_fade.start_compose(msg_type);- stream_bar.decorate(- opts.stream_id,- $("#stream_message_recipient_topic .message_header_stream"),- );+ if (msg_type === "stream") {+ stream_bar.decorate(+ opts.stream_id,+ $("#stream_message_recipient_topic .message_header_stream"),+ );+ }$(document).trigger(new $.Event("compose_started.zulip", opts));compose_recipient.update_placeholder_text();compose_recipient.update_narrow_to_recipient_visibility();@@ -148,7 +150,7 @@ export function maybe_scroll_up_selected_message() {export function fill_in_opts_from_current_narrowed_view(msg_type, opts) {return {message_type: msg_type,- stream_id: "",+ stream_id: undefined,topic: "",private_message_recipient: "",trigger: "unknown",@@ -221,10 +223,12 @@ export function start(msg_type, opts) {clear_box();}- const $stream_header_colorblock = $(- "#compose_select_recipient_widget_wrapper .stream_header_colorblock",- );- stream_bar.decorate(opts.stream_id, $stream_header_colorblock);+ if (msg_type === "stream") {+ const $stream_header_colorblock = $(+ "#compose_select_recipient_widget_wrapper .stream_header_colorblock",+ );+ stream_bar.decorate(opts.stream_id, $stream_header_colorblock);+ }if (msg_type === "private") {compose_state.set_compose_recipient_id(compose_state.DIRECT_MESSAGE_ID);diff --git a/web/src/compose_setup.js b/web/src/compose_setup.jsindex d83974589be..106cd21ca3a 100644--- a/web/src/compose_setup.js+++ b/web/src/compose_setup.js@@ -130,7 +130,7 @@ export function initialize() {event.preventDefault();const stream_id = compose_state.stream_id();- if (stream_id === "") {+ if (stream_id === undefined) {return;}const sub = stream_data.get_sub_by_id(stream_id);diff --git a/web/src/compose_state.js b/web/src/compose_state.jsindex f27d10917d3..01e43e7cfd1 100644--- a/web/src/compose_state.js+++ b/web/src/compose_state.js@@ -85,7 +85,7 @@ export function stream_id() {if (typeof stream_id === "number") {return stream_id;}- return "";+ return undefined;}export function stream_name() {@@ -162,7 +162,7 @@ export function focus_in_empty_compose(consider_start_of_whitespace_message_emptcase "stream_message_recipient_topic":return topic() === "";case "compose_select_recipient_widget_wrapper":- return stream_id() === "";+ return stream_id() === undefined;}return false;@@ -182,7 +182,7 @@ export function has_message_content() {export function has_full_recipient() {if (message_type === "stream") {- return stream_id() !== "" && topic() !== "";+ return stream_id() !== undefined && topic() !== "";}return private_message_recipient() !== "";}diff --git a/web/src/compose_validate.js b/web/src/compose_validate.jsindex 7bad3a7866b..2550febdee2 100644--- a/web/src/compose_validate.js+++ b/web/src/compose_validate.js@@ -79,7 +79,7 @@ function get_stream_id_for_textarea($textarea) {return Number.parseInt(stream_id_str, 10);}- return compose_state.stream_id() || undefined;+ return compose_state.stream_id();}export function warn_if_private_stream_is_linked(linked_stream, $textarea) {@@ -480,7 +480,7 @@ export function validate_stream_message_address_info(stream_name) {function validate_stream_message(scheduling_message) {const stream_id = compose_state.stream_id();const $banner_container = $("#compose_banners");- if (stream_id === "") {+ if (stream_id === undefined) {compose_banner.show_error_message($t({defaultMessage: "Please specify a stream."}),compose_banner.CLASSNAMES.missing_stream,diff --git a/web/src/drafts_overlay_ui.js b/web/src/drafts_overlay_ui.jsindex 68a8fd61671..e9aca581591 100644--- a/web/src/drafts_overlay_ui.js+++ b/web/src/drafts_overlay_ui.js@@ -26,7 +26,7 @@ function restore_draft(draft_id) {const compose_args = {...drafts.restore_message(draft), draft_id};if (compose_args.type === "stream") {- if (draft.stream_id !== "" && draft.topic !== "") {+ if (draft.stream_id !== undefined && draft.topic !== "") {narrow.activate([{operator: "stream", operand: compose_args.stream_name},diff --git a/web/src/pill_typeahead.js b/web/src/pill_typeahead.jsindex dfac88454da..9d73b8876b6 100644--- a/web/src/pill_typeahead.js+++ b/web/src/pill_typeahead.js@@ -112,7 +112,7 @@ export function set_up($input, pills, opts) {return typeahead_helper.sort_recipients({users,query,- current_stream_id: "",+ current_stream_id: undefined,current_topic: undefined,groups,max_num_items: undefined,diff --git a/web/src/stream_bar.js b/web/src/stream_bar.jsindex 5d438a7d9ae..9585a56dea3 100644--- a/web/src/stream_bar.js+++ b/web/src/stream_bar.js@@ -5,9 +5,6 @@ import * as stream_data from "./stream_data";// (In particular, if there's a color associated with it,// have that color be reflected here too.)export function decorate(stream_id, $element) {- if (stream_id === undefined) {- return;- }const color = stream_data.get_color(stream_id);$element.css("background-color", color);}diff --git a/web/tests/compose.test.js b/web/tests/compose.test.jsindex 4559c709973..8149d3777a6 100644--- a/web/tests/compose.test.js+++ b/web/tests/compose.test.js@@ -198,7 +198,7 @@ test_ui("send_message", ({override, override_rewire, mock_template}) => {sender_id: new_user.user_id,queue_id: undefined,resend: false,- stream_id: "",+ stream_id: undefined,topic: "",to: `[${alice.user_id}]`,reply_to: "[email protected]",diff --git a/web/tests/compose_actions.test.js b/web/tests/compose_actions.test.jsindex f5c09e2e04c..1c2d422984a 100644--- a/web/tests/compose_actions.test.js+++ b/web/tests/compose_actions.test.js@@ -127,7 +127,7 @@ test("start", ({override, override_rewire, mock_template}) => {// Start stream messagecompose_defaults = {- stream_id: "",+ stream_id: undefined,topic: "topic1",};diff --git a/web/tests/compose_ui.test.js b/web/tests/compose_ui.test.jsindex f0753715b90..fb08ca24871 100644--- a/web/tests/compose_ui.test.js+++ b/web/tests/compose_ui.test.js@@ -187,7 +187,7 @@ run_test("replace_syntax", ({override}) => {run_test("compute_placeholder_text", () => {let opts = {message_type: "stream",- stream_id: "",+ stream_id: undefined,topic: "",private_message_recipient: "",};@@ -216,7 +216,7 @@ run_test("compute_placeholder_text", () => {// direct message narrowsopts = {message_type: "private",- stream_id: "",+ stream_id: undefined,topic: "",private_message_recipient: "",};diff --git a/web/tests/stream_data.test.js b/web/tests/stream_data.test.jsindex c2f500f538a..7a9956ccab4 100644--- a/web/tests/stream_data.test.js+++ b/web/tests/stream_data.test.js@@ -139,7 +139,7 @@ test("basics", () => {assert.ok(!stream_data.is_invite_only_by_stream_id(1000));assert.equal(stream_data.get_color(social.stream_id), "red");- assert.equal(stream_data.get_color(""), "#c2c2c2");+ assert.equal(stream_data.get_color(undefined), "#c2c2c2");assert.equal(stream_data.get_name("denMARK"), "Denmark");assert.equal(stream_data.get_name("unknown Stream"), "unknown Stream");diff --git a/web/tests/typeahead_helper.test.js b/web/tests/typeahead_helper.test.jsindex 71bfeb3b8d3..f8a7d8b9d9b 100644--- a/web/tests/typeahead_helper.test.js+++ b/web/tests/typeahead_helper.test.js@@ -498,7 +498,7 @@ test("sort_recipients dup bots", () => {const recipients = th.sort_recipients({users: dup_objects,query: "b",- current_stream_id: "",+ current_stream_id: undefined,current_topic: "",});const recipients_email = recipients.map((person) => person.email);