inbox_util: Move is_in_focus to inbox_ui.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-02 14:06:45 -07:00 committed by Tim Abbott
parent 919381e5e7
commit 73507ee2ae
3 changed files with 19 additions and 20 deletions

View File

@ -22,7 +22,6 @@ import * as hash_util from "./hash_util";
import * as hashchange from "./hashchange";
import * as hotspots from "./hotspots";
import * as inbox_ui from "./inbox_ui";
import * as inbox_util from "./inbox_util";
import * as lightbox from "./lightbox";
import * as list_util from "./list_util";
import * as message_edit from "./message_edit";
@ -257,7 +256,7 @@ export function process_escape_key(e) {
return true;
}
if (inbox_util.is_in_focus() && inbox_ui.change_focused_element("escape")) {
if (inbox_ui.is_in_focus() && inbox_ui.change_focused_element("escape")) {
return true;
}
@ -663,7 +662,7 @@ export function process_hotkey(e, hotkey) {
case "vim_down":
case "vim_left":
case "vim_right":
if (inbox_util.is_in_focus()) {
if (inbox_ui.is_in_focus()) {
return inbox_ui.change_focused_element(event_name);
}
}

View File

@ -8,13 +8,17 @@ import render_user_with_status_icon from "../templates/user_with_status_icon.hbs
import * as buddy_data from "./buddy_data";
import * as compose_closed_ui from "./compose_closed_ui";
import * as compose_state from "./compose_state";
import * as hash_util from "./hash_util";
import {is_visible, set_visible} from "./inbox_util";
import * as keydown_util from "./keydown_util";
import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area";
import {localstorage} from "./localstorage";
import * as message_store from "./message_store";
import * as overlays from "./overlays";
import * as people from "./people";
import * as popovers from "./popovers";
import * as sidebar_ui from "./sidebar_ui";
import * as stream_color from "./stream_color";
import * as stream_data from "./stream_data";
import * as sub_store from "./sub_store";
@ -928,6 +932,19 @@ function move_focus_to_visible_area() {
revive_current_focus();
}
export function is_in_focus() {
// Check if user is focused on
// inbox
return (
is_visible() &&
!compose_state.composing() &&
!popovers.any_active() &&
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
!overlays.is_overlay_or_modal_open() &&
!$(".home-page-input").is(":focus")
);
}
export function initialize() {
$(document).on(
"scroll",

View File

@ -1,9 +1,5 @@
import $ from "jquery";
import * as compose_state from "./compose_state";
import * as overlays from "./overlays";
import * as popovers from "./popovers";
import * as sidebar_ui from "./sidebar_ui";
import * as stream_color from "./stream_color";
import * as stream_data from "./stream_data";
@ -21,19 +17,6 @@ export function get_dm_key(msg) {
return "dm:" + msg.other_user_id;
}
export function is_in_focus() {
// Check if user is focused on
// inbox
return (
is_visible() &&
!compose_state.composing() &&
!popovers.any_active() &&
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
!overlays.is_overlay_or_modal_open() &&
!$(".home-page-input").is(":focus")
);
}
export function update_stream_colors() {
if (!is_visible()) {
return;