mirror of https://github.com/zulip/zulip.git
stream_id: Replace empty string with undefined.
This commit also limits `stream_bar.decorate` to only be able to be called for stream messages, since it's an undefined string_id is no longer a sign that you're dealing with a DM.
This commit is contained in:
parent
07e6bcda7c
commit
77fc836edf
|
@ -218,7 +218,6 @@ EXEMPT_FILES = make_set(
|
||||||
"web/src/spectators.ts",
|
"web/src/spectators.ts",
|
||||||
"web/src/spoilers.ts",
|
"web/src/spoilers.ts",
|
||||||
"web/src/starred_messages_ui.js",
|
"web/src/starred_messages_ui.js",
|
||||||
"web/src/stream_bar.js",
|
|
||||||
"web/src/stream_color.js",
|
"web/src/stream_color.js",
|
||||||
"web/src/stream_color_events.js",
|
"web/src/stream_color_events.js",
|
||||||
"web/src/stream_create.js",
|
"web/src/stream_create.js",
|
||||||
|
|
|
@ -68,7 +68,7 @@ export function create_message_object() {
|
||||||
content: compose_state.message_content(),
|
content: compose_state.message_content(),
|
||||||
sender_id: page_params.user_id,
|
sender_id: page_params.user_id,
|
||||||
queue_id: page_params.queue_id,
|
queue_id: page_params.queue_id,
|
||||||
stream_id: "",
|
stream_id: undefined,
|
||||||
};
|
};
|
||||||
message.topic = "";
|
message.topic = "";
|
||||||
|
|
||||||
|
|
|
@ -111,10 +111,12 @@ export function complete_starting_tasks(msg_type, opts) {
|
||||||
|
|
||||||
maybe_scroll_up_selected_message();
|
maybe_scroll_up_selected_message();
|
||||||
compose_fade.start_compose(msg_type);
|
compose_fade.start_compose(msg_type);
|
||||||
stream_bar.decorate(
|
if (msg_type === "stream") {
|
||||||
opts.stream_id,
|
stream_bar.decorate(
|
||||||
$("#stream_message_recipient_topic .message_header_stream"),
|
opts.stream_id,
|
||||||
);
|
$("#stream_message_recipient_topic .message_header_stream"),
|
||||||
|
);
|
||||||
|
}
|
||||||
$(document).trigger(new $.Event("compose_started.zulip", opts));
|
$(document).trigger(new $.Event("compose_started.zulip", opts));
|
||||||
compose_recipient.update_placeholder_text();
|
compose_recipient.update_placeholder_text();
|
||||||
compose_recipient.update_narrow_to_recipient_visibility();
|
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) {
|
export function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
|
||||||
return {
|
return {
|
||||||
message_type: msg_type,
|
message_type: msg_type,
|
||||||
stream_id: "",
|
stream_id: undefined,
|
||||||
topic: "",
|
topic: "",
|
||||||
private_message_recipient: "",
|
private_message_recipient: "",
|
||||||
trigger: "unknown",
|
trigger: "unknown",
|
||||||
|
@ -221,10 +223,12 @@ export function start(msg_type, opts) {
|
||||||
clear_box();
|
clear_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
const $stream_header_colorblock = $(
|
if (msg_type === "stream") {
|
||||||
"#compose_select_recipient_widget_wrapper .stream_header_colorblock",
|
const $stream_header_colorblock = $(
|
||||||
);
|
"#compose_select_recipient_widget_wrapper .stream_header_colorblock",
|
||||||
stream_bar.decorate(opts.stream_id, $stream_header_colorblock);
|
);
|
||||||
|
stream_bar.decorate(opts.stream_id, $stream_header_colorblock);
|
||||||
|
}
|
||||||
|
|
||||||
if (msg_type === "private") {
|
if (msg_type === "private") {
|
||||||
compose_state.set_compose_recipient_id(compose_state.DIRECT_MESSAGE_ID);
|
compose_state.set_compose_recipient_id(compose_state.DIRECT_MESSAGE_ID);
|
||||||
|
|
|
@ -130,7 +130,7 @@ export function initialize() {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const stream_id = compose_state.stream_id();
|
const stream_id = compose_state.stream_id();
|
||||||
if (stream_id === "") {
|
if (stream_id === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sub = stream_data.get_sub_by_id(stream_id);
|
const sub = stream_data.get_sub_by_id(stream_id);
|
||||||
|
|
|
@ -85,7 +85,7 @@ export function stream_id() {
|
||||||
if (typeof stream_id === "number") {
|
if (typeof stream_id === "number") {
|
||||||
return stream_id;
|
return stream_id;
|
||||||
}
|
}
|
||||||
return "";
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stream_name() {
|
export function stream_name() {
|
||||||
|
@ -162,7 +162,7 @@ export function focus_in_empty_compose(consider_start_of_whitespace_message_empt
|
||||||
case "stream_message_recipient_topic":
|
case "stream_message_recipient_topic":
|
||||||
return topic() === "";
|
return topic() === "";
|
||||||
case "compose_select_recipient_widget_wrapper":
|
case "compose_select_recipient_widget_wrapper":
|
||||||
return stream_id() === "";
|
return stream_id() === undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -182,7 +182,7 @@ export function has_message_content() {
|
||||||
|
|
||||||
export function has_full_recipient() {
|
export function has_full_recipient() {
|
||||||
if (message_type === "stream") {
|
if (message_type === "stream") {
|
||||||
return stream_id() !== "" && topic() !== "";
|
return stream_id() !== undefined && topic() !== "";
|
||||||
}
|
}
|
||||||
return private_message_recipient() !== "";
|
return private_message_recipient() !== "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ function get_stream_id_for_textarea($textarea) {
|
||||||
return Number.parseInt(stream_id_str, 10);
|
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) {
|
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) {
|
function validate_stream_message(scheduling_message) {
|
||||||
const stream_id = compose_state.stream_id();
|
const stream_id = compose_state.stream_id();
|
||||||
const $banner_container = $("#compose_banners");
|
const $banner_container = $("#compose_banners");
|
||||||
if (stream_id === "") {
|
if (stream_id === undefined) {
|
||||||
compose_banner.show_error_message(
|
compose_banner.show_error_message(
|
||||||
$t({defaultMessage: "Please specify a stream."}),
|
$t({defaultMessage: "Please specify a stream."}),
|
||||||
compose_banner.CLASSNAMES.missing_stream,
|
compose_banner.CLASSNAMES.missing_stream,
|
||||||
|
|
|
@ -26,7 +26,7 @@ function restore_draft(draft_id) {
|
||||||
const compose_args = {...drafts.restore_message(draft), draft_id};
|
const compose_args = {...drafts.restore_message(draft), draft_id};
|
||||||
|
|
||||||
if (compose_args.type === "stream") {
|
if (compose_args.type === "stream") {
|
||||||
if (draft.stream_id !== "" && draft.topic !== "") {
|
if (draft.stream_id !== undefined && draft.topic !== "") {
|
||||||
narrow.activate(
|
narrow.activate(
|
||||||
[
|
[
|
||||||
{operator: "stream", operand: compose_args.stream_name},
|
{operator: "stream", operand: compose_args.stream_name},
|
||||||
|
|
|
@ -112,7 +112,7 @@ export function set_up($input, pills, opts) {
|
||||||
return typeahead_helper.sort_recipients({
|
return typeahead_helper.sort_recipients({
|
||||||
users,
|
users,
|
||||||
query,
|
query,
|
||||||
current_stream_id: "",
|
current_stream_id: undefined,
|
||||||
current_topic: undefined,
|
current_topic: undefined,
|
||||||
groups,
|
groups,
|
||||||
max_num_items: undefined,
|
max_num_items: undefined,
|
||||||
|
|
|
@ -5,9 +5,6 @@ import * as stream_data from "./stream_data";
|
||||||
// (In particular, if there's a color associated with it,
|
// (In particular, if there's a color associated with it,
|
||||||
// have that color be reflected here too.)
|
// have that color be reflected here too.)
|
||||||
export function decorate(stream_id, $element) {
|
export function decorate(stream_id, $element) {
|
||||||
if (stream_id === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const color = stream_data.get_color(stream_id);
|
const color = stream_data.get_color(stream_id);
|
||||||
$element.css("background-color", color);
|
$element.css("background-color", color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ test_ui("send_message", ({override, override_rewire, mock_template}) => {
|
||||||
sender_id: new_user.user_id,
|
sender_id: new_user.user_id,
|
||||||
queue_id: undefined,
|
queue_id: undefined,
|
||||||
resend: false,
|
resend: false,
|
||||||
stream_id: "",
|
stream_id: undefined,
|
||||||
topic: "",
|
topic: "",
|
||||||
to: `[${alice.user_id}]`,
|
to: `[${alice.user_id}]`,
|
||||||
reply_to: "alice@example.com",
|
reply_to: "alice@example.com",
|
||||||
|
|
|
@ -127,7 +127,7 @@ test("start", ({override, override_rewire, mock_template}) => {
|
||||||
|
|
||||||
// Start stream message
|
// Start stream message
|
||||||
compose_defaults = {
|
compose_defaults = {
|
||||||
stream_id: "",
|
stream_id: undefined,
|
||||||
topic: "topic1",
|
topic: "topic1",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ run_test("replace_syntax", ({override}) => {
|
||||||
run_test("compute_placeholder_text", () => {
|
run_test("compute_placeholder_text", () => {
|
||||||
let opts = {
|
let opts = {
|
||||||
message_type: "stream",
|
message_type: "stream",
|
||||||
stream_id: "",
|
stream_id: undefined,
|
||||||
topic: "",
|
topic: "",
|
||||||
private_message_recipient: "",
|
private_message_recipient: "",
|
||||||
};
|
};
|
||||||
|
@ -216,7 +216,7 @@ run_test("compute_placeholder_text", () => {
|
||||||
// direct message narrows
|
// direct message narrows
|
||||||
opts = {
|
opts = {
|
||||||
message_type: "private",
|
message_type: "private",
|
||||||
stream_id: "",
|
stream_id: undefined,
|
||||||
topic: "",
|
topic: "",
|
||||||
private_message_recipient: "",
|
private_message_recipient: "",
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,7 +139,7 @@ test("basics", () => {
|
||||||
assert.ok(!stream_data.is_invite_only_by_stream_id(1000));
|
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(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("denMARK"), "Denmark");
|
||||||
assert.equal(stream_data.get_name("unknown Stream"), "unknown Stream");
|
assert.equal(stream_data.get_name("unknown Stream"), "unknown Stream");
|
||||||
|
|
|
@ -498,7 +498,7 @@ test("sort_recipients dup bots", () => {
|
||||||
const recipients = th.sort_recipients({
|
const recipients = th.sort_recipients({
|
||||||
users: dup_objects,
|
users: dup_objects,
|
||||||
query: "b",
|
query: "b",
|
||||||
current_stream_id: "",
|
current_stream_id: undefined,
|
||||||
current_topic: "",
|
current_topic: "",
|
||||||
});
|
});
|
||||||
const recipients_email = recipients.map((person) => person.email);
|
const recipients_email = recipients.map((person) => person.email);
|
||||||
|
|
Loading…
Reference in New Issue