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_ui: Remove extra effort to return message object.

Aman Agrawal6fe93a3ff609
diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts
index 9b0739256d7..846d99521c8 100644
--- a/web/src/inbox_ui.ts
+++ b/web/src/inbox_ui.ts
@@ -949,24 +949,22 @@ export function get_focused_row_message(): {message?: Message | undefined} & (
return {message};
}
- const $stream = $focused_row.parent(".inbox-topic-container").parent();
- const stream_key = $stream.attr("id");
- assert(stream_key !== undefined);
- const row_info = topics_dict.get(stream_key)!.get(conversation_key);
- assert(row_info !== undefined);
- const message = message_store.get(row_info.latest_msg_id);
+ // Last case: focused on a topic row.
// 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) {
- return {
- msg_type: "stream",
- stream_id: row_info.stream_id,
- topic: row_info.topic_name,
- };
- }
- return {message};
+ const $topic_menu_elt = $focused_row.find(".inbox-topic-menu");
+ const topic = $topic_menu_elt.attr("data-topic-name");
+ assert(topic !== undefined);
+ const stream_id = Number($topic_menu_elt.attr("data-stream-id"));
+ assert(stream_id !== undefined);
+
+ return {
+ msg_type: "stream",
+ stream_id,
+ topic,
+ };
}
export function toggle_topic_visibility_policy(): boolean {