mirror of https://github.com/zulip/zulip.git
compose_recipients: Fix broken compose state after restoring draft.
After restoring a draft with no recipient, compose was broken as `message_type` assertion fails.
This commit is contained in:
parent
5b3641d92d
commit
c0706ca9f6
|
@ -12,7 +12,7 @@ import * as compose_fade from "./compose_fade";
|
||||||
import * as compose_pm_pill from "./compose_pm_pill";
|
import * as compose_pm_pill from "./compose_pm_pill";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as compose_ui from "./compose_ui";
|
import * as compose_ui from "./compose_ui";
|
||||||
import type {ComposePlaceholderOptions, ComposeTriggeredOptions} from "./compose_ui";
|
import type {ComposeTriggeredOptions} from "./compose_ui";
|
||||||
import * as compose_validate from "./compose_validate";
|
import * as compose_validate from "./compose_validate";
|
||||||
import * as drafts from "./drafts";
|
import * as drafts from "./drafts";
|
||||||
import * as dropdown_widget from "./dropdown_widget";
|
import * as dropdown_widget from "./dropdown_widget";
|
||||||
|
@ -362,22 +362,21 @@ export function update_placeholder_text(): void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const message_type = compose_state.get_message_type();
|
const message_type = compose_state.get_message_type();
|
||||||
assert(message_type !== undefined);
|
|
||||||
|
|
||||||
let opts: ComposePlaceholderOptions;
|
let placeholder = compose_ui.DEFAULT_COMPOSE_PLACEHOLDER;
|
||||||
if (message_type === "stream") {
|
if (message_type === "stream") {
|
||||||
const stream_id = compose_state.stream_id();
|
const stream_id = compose_state.stream_id();
|
||||||
opts = {
|
placeholder = compose_ui.compute_placeholder_text({
|
||||||
message_type,
|
message_type,
|
||||||
stream_id,
|
stream_id,
|
||||||
topic: compose_state.topic(),
|
topic: compose_state.topic(),
|
||||||
};
|
});
|
||||||
} else {
|
} else if (message_type === "private") {
|
||||||
opts = {
|
placeholder = compose_ui.compute_placeholder_text({
|
||||||
message_type,
|
message_type,
|
||||||
direct_message_user_ids: compose_pm_pill.get_user_ids(),
|
direct_message_user_ids: compose_pm_pill.get_user_ids(),
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$("textarea#compose-textarea").attr("placeholder", compose_ui.compute_placeholder_text(opts));
|
$("textarea#compose-textarea").attr("placeholder", placeholder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import * as stream_data from "./stream_data";
|
||||||
import * as user_status from "./user_status";
|
import * as user_status from "./user_status";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
||||||
|
export const DEFAULT_COMPOSE_PLACEHOLDER = $t({defaultMessage: "Compose your message here"});
|
||||||
|
|
||||||
export type ComposeTriggeredOptions = {
|
export type ComposeTriggeredOptions = {
|
||||||
trigger: string;
|
trigger: string;
|
||||||
} & (
|
} & (
|
||||||
|
@ -333,7 +335,7 @@ export function compute_placeholder_text(opts: ComposePlaceholderOptions): strin
|
||||||
}
|
}
|
||||||
return $t({defaultMessage: "Message {recipient_names}"}, {recipient_names});
|
return $t({defaultMessage: "Message {recipient_names}"}, {recipient_names});
|
||||||
}
|
}
|
||||||
return $t({defaultMessage: "Compose your message here"});
|
return DEFAULT_COMPOSE_PLACEHOLDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function set_compose_box_top(set_top: boolean): void {
|
export function set_compose_box_top(set_top: boolean): void {
|
||||||
|
|
Loading…
Reference in New Issue