compose: Allow stream_id of ComposeTriggeredOptions to be undefined.

This commit is contained in:
evykassirer 2024-04-04 12:46:48 -07:00 committed by Tim Abbott
parent 5e0343816f
commit 55cf08c4e6
2 changed files with 4 additions and 4 deletions

View File

@ -170,8 +170,8 @@ function switch_message_type(message_type: MessageType): void {
compose_ui.set_focus(opts);
}
function update_recipient_label(stream_id: number): void {
const stream = stream_data.get_sub_by_id(stream_id);
function update_recipient_label(stream_id?: number): void {
const stream = stream_id !== undefined ? stream_data.get_sub_by_id(stream_id) : undefined;
if (stream === undefined) {
$("#compose_select_recipient_widget .dropdown_widget_value").text(
$t({defaultMessage: "Select a stream"}),

View File

@ -28,7 +28,7 @@ export type ComposeTriggeredOptions = {
| {
message_type: "stream";
topic: string;
stream_id: number;
stream_id?: number;
}
| {
message_type: "private";
@ -102,7 +102,7 @@ function get_focus_area(opts: ComposeTriggeredOptions): string {
if (opts.message_type === "stream" && opts.stream_id && !opts.topic) {
return "input#stream_message_recipient_topic";
} else if (
(opts.message_type === "stream" && opts.stream_id) ||
(opts.message_type === "stream" && opts.stream_id !== undefined) ||
(opts.message_type === "private" && opts.private_message_recipient)
) {
if (opts.trigger === "clear topic button") {