Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose_ui: Fix incorrect ComposePlaceholderOptions type.

Tim Abbottf16c32e3a465
diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.ts
index 8c2eeefb0e7..c6f80ef0a73 100644
--- a/web/src/compose_ui.ts
+++ b/web/src/compose_ui.ts
@@ -38,7 +38,7 @@ type ComposeTriggeredOptions = {
type ComposePlaceholderOptions =
| {
message_type: "stream";
- stream_id: number;
+ stream_id: number | undefined;
topic: string;
}
| {
@@ -294,8 +294,13 @@ export function compute_placeholder_text(opts: ComposePlaceholderOptions): strin
// because the caller is expected to insert this into the
// placeholder field in a way that does HTML escaping.
if (opts.message_type === "stream") {
- const stream = stream_data.get_sub_by_id(opts.stream_id);
- const stream_name = stream ? stream.name : "";
+ let stream_name = "";
+ if (opts.stream_id !== undefined) {
+ const stream = stream_data.get_sub_by_id(opts.stream_id);
+ if (stream !== undefined) {
+ stream_name = stream.name;
+ }
+ }
if (stream_name && opts.topic) {
return $t(