compose: Open the compose box with channel picker.

This commit changes the code in such a way that the
"Start new conversation" button open the compose box with the channel
picker open, as we do when no channels is selected.

Fixes #28410.

Co-authored-by: Kunal Sharma <v.shm.kunal@gmail.com>
This commit is contained in:
Maneesh Shukla 2024-11-03 19:34:52 +05:30
parent 00ca7621e1
commit 542ff61083
2 changed files with 13 additions and 1 deletions

View File

@ -328,9 +328,20 @@ export let start = (raw_opts: ComposeActionsStartOpts): void => {
if (opts.message_type === "private") {
compose_state.set_compose_recipient_id(compose_state.DIRECT_MESSAGE_ID);
compose_recipient.on_compose_select_recipient_update();
} else if (opts.stream_id) {
} else if (opts.stream_id && opts.topic) {
compose_state.set_stream_id(opts.stream_id);
compose_recipient.on_compose_select_recipient_update();
} else if (opts.stream_id) {
const stream = stream_data.get_sub_by_id(opts.stream_id);
if (stream && stream_data.can_post_messages_in_stream(stream)) {
compose_state.set_stream_id(opts.stream_id);
compose_recipient.on_compose_select_recipient_update();
} else {
opts.stream_id = undefined;
compose_state.set_stream_id("");
opts.topic = "";
compose_recipient.open_compose_recipient_dropdown();
}
} else {
// Open stream selection dropdown if no stream is selected.
compose_state.set_stream_id("");

View File

@ -142,6 +142,7 @@ test("start", ({override, override_rewire, mock_template}) => {
override_rewire(compose_actions, "clear_textarea", noop);
override_rewire(compose_recipient, "on_compose_select_recipient_update", noop);
override_rewire(compose_recipient, "check_posting_policy_for_compose_box", noop);
override_rewire(stream_data, "can_post_messages_in_stream", () => true);
mock_template("inline_decorated_stream_name.hbs", false, noop);
let compose_defaults;