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: Rename `current_focus_id` for clarity.

Aman Agrawal2aa2bb41baa0
diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts
index dc6eff2f13c..f689c544c24 100644
--- a/web/src/inbox_ui.ts
+++ b/web/src/inbox_ui.ts
@@ -240,7 +240,9 @@ let inbox_last_search_keyword = "";
const per_channel_last_search_keyword = new Map<number, string>();
const INBOX_SEARCH_ID = "inbox-search";
const INBOX_FILTERS_DROPDOWN_ID = "inbox-filter_widget";
-export let current_focus_id: string | undefined;
+// This tracks the current navigation element / area
+// that user is in, it may not be the same as the focused element.
+export let current_navigated_id: string | undefined;
const STREAM_HEADER_PREFIX = "inbox-stream-header-";
const CONVERSATION_ID_PREFIX = "inbox-row-conversation-";
@@ -1313,7 +1315,7 @@ export function search_and_update(): void {
return;
}
search_keyword = new_keyword;
- current_focus_id = INBOX_SEARCH_ID;
+ current_navigated_id = INBOX_SEARCH_ID;
update_triggered_by_user = true;
update();
}
@@ -1494,12 +1496,12 @@ function expand_all_folders_and_channels(): void {
}
function focus_current_id(): void {
- assert(current_focus_id !== undefined);
- $(`#${CSS.escape(current_focus_id)}`).trigger("focus");
+ assert(current_navigated_id !== undefined);
+ $(`#${CSS.escape(current_navigated_id)}`).trigger("focus");
}
function focus_inbox_search(): void {
- current_focus_id = INBOX_SEARCH_ID;
+ current_navigated_id = INBOX_SEARCH_ID;
focus_current_id();
}
@@ -1508,8 +1510,8 @@ function is_navigated_to_list(): boolean {
// focused or was the last focused element in inbox
// that user can navigate to.
return (
- current_focus_id === undefined ||
- ![INBOX_SEARCH_ID, INBOX_FILTERS_DROPDOWN_ID].includes(current_focus_id)
+ current_navigated_id === undefined ||
+ ![INBOX_SEARCH_ID, INBOX_FILTERS_DROPDOWN_ID].includes(current_navigated_id)
);
}
@@ -1547,7 +1549,7 @@ function get_row_index($elt: JQuery): number {
function focus_clicked_list_element($elt: JQuery): void {
row_focus = get_row_index($elt);
update_triggered_by_user = true;
- current_focus_id = $elt.closest(".inbox-row, .inbox-header").attr("id");
+ current_navigated_id = $elt.closest(".inbox-row, .inbox-header").attr("id");
}
export function revive_current_focus(): void {
@@ -1605,7 +1607,7 @@ export function get_focused_row_message(): {message?: Message | undefined} & (
const $all_rows = get_all_rows();
const focused_row = $all_rows.get(row_focus);
if (!focused_row) {
- // Likely `row_focus` or `current_focus_id` wasn't updated correctly.
+ // Likely `row_focus` or `current_navigated_id` wasn't updated correctly.
// TODO: Debug this further.
return {message: undefined};
}
@@ -1703,7 +1705,7 @@ function set_list_focus(input_key?: string): void {
assert(row_to_focus !== undefined);
const $row_to_focus = $(row_to_focus);
- current_focus_id = $row_to_focus.attr("id");
+ current_navigated_id = $row_to_focus.attr("id");
const is_header_row = is_row_a_header($row_to_focus);
update_closed_compose_text($row_to_focus, is_header_row);
if (col_focus > COLUMNS.ACTION_MENU) {
@@ -1747,7 +1749,7 @@ function set_list_focus(input_key?: string): void {
}
function focus_filters_dropdown(): void {
- current_focus_id = INBOX_FILTERS_DROPDOWN_ID;
+ current_navigated_id = INBOX_FILTERS_DROPDOWN_ID;
$(`#${CSS.escape(INBOX_FILTERS_DROPDOWN_ID)}`).trigger("focus");
}
@@ -1755,14 +1757,14 @@ function is_navigated_to_search(): boolean {
// We check if the inbox search is either currently
// focused or was the last focused element in inbox
// that user can navigate to.
- return current_focus_id === INBOX_SEARCH_ID;
+ return current_navigated_id === INBOX_SEARCH_ID;
}
function is_navigated_to_filters_dropdown(): boolean {
// We check if the filters dropdown is either currently
// focused or was the last focused element in inbox
// that user can navigate to.
- return current_focus_id === INBOX_FILTERS_DROPDOWN_ID;
+ return current_navigated_id === INBOX_FILTERS_DROPDOWN_ID;
}
function get_page_up_down_delta(): number {
@@ -1824,7 +1826,7 @@ export function change_focused_element(input_key: string): boolean {
return true;
}
row_focus = get_row_index($first_row);
- current_focus_id = $first_row.attr("id");
+ current_navigated_id = $first_row.attr("id");
$first_row.trigger("focus");
}
@@ -1846,7 +1848,7 @@ export function change_focused_element(input_key: string): boolean {
post_tab_focus_elem.id === INBOX_SEARCH_ID ||
post_tab_focus_elem.id === INBOX_FILTERS_DROPDOWN_ID
) {
- current_focus_id = post_tab_focus_elem.id;
+ current_navigated_id = post_tab_focus_elem.id;
}
const row_to_focus = post_tab_focus_elem.closest(".inbox-row, .inbox-header");
@@ -1858,7 +1860,7 @@ export function change_focused_element(input_key: string): boolean {
return;
}
- current_focus_id = row_to_focus.id;
+ current_navigated_id = row_to_focus.id;
row_focus = get_row_index($(row_to_focus));
col_focus = Number.parseInt(col_index, 10);
}
@@ -2455,7 +2457,7 @@ export function initialize({hide_other_views}: {hide_other_views: () => void}):
});
$("body").on("click", "#inbox-search", () => {
- current_focus_id = INBOX_SEARCH_ID;
+ current_navigated_id = INBOX_SEARCH_ID;
compose_closed_ui.set_standard_text_for_reply_button();
});