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: Handle latest message not fetched when replying.

Aman Agrawal9fc6af220e02
diff --git a/web/src/compose_reply.js b/web/src/compose_reply.js
index c94fe94d1b3..9e88169c0e7 100644
--- a/web/src/compose_reply.js
+++ b/web/src/compose_reply.js
@@ -34,7 +34,7 @@ export function respond_to_message(opts) {
if (message_opts.message === undefined) {
compose_actions.start(message_opts.msg_type, {
trigger: "inbox_nofocus",
- stream_id: message_opts.stream_id,
+ ...message_opts,
});
return;
}
diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js
index c0f5341f0fa..bf614dcce8f 100644
--- a/web/src/inbox_ui.js
+++ b/web/src/inbox_ui.js
@@ -711,15 +711,36 @@ export function get_focused_row_message() {
const is_dm = $focused_row.parent("#inbox-direct-messages-container").length > 0;
const conversation_key = $focused_row.attr("id").slice(CONVERSATION_ID_PREFIX.length);
- let latest_msg_id;
+ let row_info;
if (is_dm) {
- latest_msg_id = dms_dict.get(conversation_key).latest_msg_id;
+ row_info = dms_dict.get(conversation_key);
} else {
const $stream = $focused_row.parent(".inbox-topic-container").parent();
const stream_key = $stream.attr("id");
- latest_msg_id = topics_dict.get(stream_key).get(conversation_key).latest_msg_id;
+ row_info = topics_dict.get(stream_key).get(conversation_key);
}
- return {message: message_store.get(latest_msg_id)};
+
+ const message = message_store.get(row_info.latest_msg_id);
+ // Since inbox is populated based on unread data which is part
+ // of /register request, it is possible that we don't have the
+ // actual message in our message_store. In that case, we return
+ // a fake message object.
+ if (message === undefined) {
+ if (is_dm) {
+ const recipients = people.user_ids_string_to_emails_string(row_info.user_ids_string);
+ return {
+ msg_type: "private",
+ private_message_recipient: recipients,
+ };
+ }
+ return {
+ msg_type: "stream",
+ stream_id: row_info.stream_id,
+ topic: row_info.topic_name,
+ };
+ }
+
+ return {message};
}
function is_row_a_header($row) {