Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent_view: Extract the focused row.
Aman Agrawal11b6ebfd387a
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.tsindex 7c997c8cef1..0fe6018fe2c 100644--- a/web/src/recent_view_ui.ts+++ b/web/src/recent_view_ui.ts@@ -509,7 +509,7 @@ function set_table_focus(row: number, col: number, using_keyboard = false): boolreturn true;}-export function get_focused_row_message(): Message | undefined {+function get_focused_row(): JQuery | undefined {if (is_table_focused()) {assert(topics_widget !== undefined);if (topics_widget.get_current_list().length === 0) {@@ -524,17 +524,25 @@ export function get_focused_row_message(): Message | undefined {// purpose of this function.return undefined;}- const topic_id = $topic_row.attr("id");- assert(topic_id !== undefined);- const conversation_id = topic_id.slice(recent_conversation_key_prefix.length);- const last_conversation = recent_view_data.conversations.get(conversation_id);- assert(last_conversation !== undefined);- const topic_last_msg_id = last_conversation.last_msg_id;- return message_store.get(topic_last_msg_id);+ return $topic_row;}return undefined;}+export function get_focused_row_message(): Message | undefined {+ const $topic_row = get_focused_row();+ if ($topic_row === undefined) {+ return undefined;+ }+ const topic_id = $topic_row.attr("id");+ assert(topic_id !== undefined);+ const conversation_id = topic_id.slice(recent_conversation_key_prefix.length);+ const last_conversation = recent_view_data.conversations.get(conversation_id);+ assert(last_conversation !== undefined);+ const topic_last_msg_id = last_conversation.last_msg_id;+ return message_store.get(topic_last_msg_id);+}+export function revive_current_focus(): boolean {// After re-render, the current_focus_elem is no longer linked// to the focused element, this function attempts to revive the