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 3be633224e
commit ca2c3cbad6
2 changed files with 13 additions and 3 deletions

View File

@ -328,9 +328,19 @@ 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;
@ -333,7 +334,6 @@ test("respond_to_message", ({override, override_rewire, mock_template}) => {
test("reply_with_mention", ({override, override_rewire, mock_template}) => {
mock_banners();
compose_state.set_message_type("stream");
override_rewire(compose_recipient, "on_compose_select_recipient_update", noop);
override_rewire(compose_actions, "complete_starting_tasks", noop);
override_rewire(compose_actions, "clear_textarea", noop);
override_private_message_recipient({override});