From 73507ee2aef7b0f4ee7b42d57d0d0546888c90e9 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 2 Oct 2023 14:06:45 -0700 Subject: [PATCH] inbox_util: Move is_in_focus to inbox_ui. Signed-off-by: Anders Kaseorg --- web/src/hotkey.js | 5 ++--- web/src/inbox_ui.js | 17 +++++++++++++++++ web/src/inbox_util.js | 17 ----------------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/web/src/hotkey.js b/web/src/hotkey.js index 281b003fa7..c2ab1ace68 100644 --- a/web/src/hotkey.js +++ b/web/src/hotkey.js @@ -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); } } diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js index c625f545d6..7ebbfec006 100644 --- a/web/src/inbox_ui.js +++ b/web/src/inbox_ui.js @@ -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", diff --git a/web/src/inbox_util.js b/web/src/inbox_util.js index 48fb354370..becad1cb02 100644 --- a/web/src/inbox_util.js +++ b/web/src/inbox_util.js @@ -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;