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
1 changed files with 8 additions and 3 deletions

View File

@ -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(