compose_ui: Fix incorrect ComposePlaceholderOptions type.

When opening compose without a stream prefilled from say the inbox
view, stream_id will be undefined here.
This commit is contained in:
Tim Abbott
2024-04-01 20:42:58 -07:00
parent d5422fe7c8
commit f16c32e3a4

View File

@@ -38,7 +38,7 @@ type ComposeTriggeredOptions = {
type ComposePlaceholderOptions = type ComposePlaceholderOptions =
| { | {
message_type: "stream"; message_type: "stream";
stream_id: number; stream_id: number | undefined;
topic: string; topic: string;
} }
| { | {
@@ -294,8 +294,13 @@ export function compute_placeholder_text(opts: ComposePlaceholderOptions): strin
// because the caller is expected to insert this into the // because the caller is expected to insert this into the
// placeholder field in a way that does HTML escaping. // placeholder field in a way that does HTML escaping.
if (opts.message_type === "stream") { if (opts.message_type === "stream") {
const stream = stream_data.get_sub_by_id(opts.stream_id); let stream_name = "";
const stream_name = stream ? 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) { if (stream_name && opts.topic) {
return $t( return $t(