Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

inbox: Fill compose with dm/stream info for `reply` on inbox-header.

Aman Agrawalbb740ca65efb
diff --git a/web/src/compose_reply.js b/web/src/compose_reply.js
index b86f885e943..4b0e4313e53 100644
--- a/web/src/compose_reply.js
+++ b/web/src/compose_reply.js
@@ -30,13 +30,15 @@ export function respond_to_message(opts) {
return;
}
} else if (inbox_util.is_visible()) {
- message = inbox_ui.get_focused_row_message();
- if (message === undefined) {
- // Open empty compose with nothing pre-filled since
- // user is not focused on any table row.
- compose_actions.start("stream", {trigger: "inbox_nofocus"});
+ const message_opts = inbox_ui.get_focused_row_message();
+ if (message_opts.message === undefined) {
+ compose_actions.start(message_opts.msg_type, {
+ trigger: "inbox_nofocus",
+ stream_id: message_opts.stream_id,
+ });
return;
}
+ message = message_opts.message;
} else {
message = message_lists.current.selected_message();
diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js
index d5491b02360..c0f5341f0fa 100644
--- a/web/src/inbox_ui.js
+++ b/web/src/inbox_ui.js
@@ -693,13 +693,20 @@ function update_closed_compose_text($row, is_header_row) {
export function get_focused_row_message() {
if (!is_list_focused()) {
- return undefined;
+ return {message: undefined};
}
const $all_rows = get_all_rows();
const $focused_row = $($all_rows.get(row_focus));
if (is_row_a_header($focused_row)) {
- return undefined;
+ const is_dm_header = $focused_row.attr("id") === "inbox-dm-header";
+ if (is_dm_header) {
+ return {message: undefined, msg_type: "private"};
+ }
+
+ const stream_id = Number.parseInt($focused_row.attr("data-stream-id"), 10);
+ compose_state.set_compose_recipient_id(stream_id);
+ return {message: undefined, msg_type: "stream", stream_id};
}
const is_dm = $focused_row.parent("#inbox-direct-messages-container").length > 0;
@@ -712,7 +719,7 @@ export function get_focused_row_message() {
const stream_key = $stream.attr("id");
latest_msg_id = topics_dict.get(stream_key).get(conversation_key).latest_msg_id;
}
- return message_store.get(latest_msg_id);
+ return {message: message_store.get(latest_msg_id)};
}
function is_row_a_header($row) {