diff --git a/web/src/hashchange.js b/web/src/hashchange.js index 6c79143e5b..bd62bf4e33 100644 --- a/web/src/hashchange.js +++ b/web/src/hashchange.js @@ -15,7 +15,6 @@ import * as message_lists from "./message_lists"; import * as message_scroll from "./message_scroll"; import * as message_viewport from "./message_viewport"; import * as narrow from "./narrow"; -import * as navigate from "./navigate"; import * as overlays from "./overlays"; import {page_params} from "./page_params"; import * as popovers from "./popovers"; @@ -58,7 +57,7 @@ function show_all_message_view() { narrow.deactivate(!(coming_from_recent_view || coming_from_inbox), is_actively_scrolling); // We need to maybe scroll to the selected message // once we have the proper viewport set up - setTimeout(navigate.maybe_scroll_to_selected, 0); + setTimeout(message_viewport.maybe_scroll_to_selected, 0); } export function set_hash_to_default_view() { diff --git a/web/src/message_viewport.js b/web/src/message_viewport.js index d7ddede6bc..3a946770f7 100644 --- a/web/src/message_viewport.js +++ b/web/src/message_viewport.js @@ -483,6 +483,28 @@ export function keep_pointer_in_view() { message_lists.current.select_id(rows.id($next_row), {from_scroll: true}); } +export function scroll_to_selected() { + const $selected_row = message_lists.current.selected_row(); + if ($selected_row && $selected_row.length !== 0) { + recenter_view($selected_row); + } +} + +export let scroll_to_selected_planned = false; + +export function plan_scroll_to_selected() { + scroll_to_selected_planned = true; +} + +export function maybe_scroll_to_selected() { + // If we have made a plan to scroll to the selected message but + // deferred doing so, do so here. + if (scroll_to_selected_planned) { + scroll_to_selected(); + scroll_to_selected_planned = false; + } +} + export function initialize() { $jwindow = $(window); $scroll_container = $("html"); diff --git a/web/src/navigate.js b/web/src/navigate.js index beee0310e7..1b4cbd8044 100644 --- a/web/src/navigate.js +++ b/web/src/navigate.js @@ -116,25 +116,3 @@ export function page_down() { page_down_the_right_amount(); } } - -export function scroll_to_selected() { - const $selected_row = message_lists.current.selected_row(); - if ($selected_row && $selected_row.length !== 0) { - message_viewport.recenter_view($selected_row); - } -} - -let scroll_to_selected_planned = false; - -export function plan_scroll_to_selected() { - scroll_to_selected_planned = true; -} - -export function maybe_scroll_to_selected() { - // If we have made a plan to scroll to the selected message but - // deferred doing so, do so here. - if (scroll_to_selected_planned) { - scroll_to_selected(); - scroll_to_selected_planned = false; - } -} diff --git a/web/src/resize_handler.js b/web/src/resize_handler.js index 6f03754042..63c01c5b43 100644 --- a/web/src/resize_handler.js +++ b/web/src/resize_handler.js @@ -3,7 +3,7 @@ import $ from "jquery"; import * as compose_ui from "./compose_ui"; import * as condense from "./condense"; import * as message_lists from "./message_lists"; -import * as navigate from "./navigate"; +import * as message_viewport from "./message_viewport"; import * as popover_menus from "./popover_menus"; import * as popovers from "./popovers"; import * as resize from "./resize"; @@ -42,6 +42,6 @@ export function handler() { popover_menus.set_suppress_scroll_hide(); } - navigate.scroll_to_selected(); + message_viewport.scroll_to_selected(); } } diff --git a/web/src/ui_init.js b/web/src/ui_init.js index 0df8e1cb2e..ec843ab9df 100644 --- a/web/src/ui_init.js +++ b/web/src/ui_init.js @@ -677,7 +677,7 @@ export function initialize_everything() { desktop_notifications.initialize(); audible_notifications.initialize(); compose_notifications.initialize({ - on_click_scroll_to_selected: navigate.scroll_to_selected, + on_click_scroll_to_selected: message_viewport.scroll_to_selected, on_narrow_to_recipient(message_id) { narrow.by_topic(message_id, {trigger: "compose_notification"}); }, diff --git a/web/src/views_util.js b/web/src/views_util.js index 5d2ce2de90..0a09a3b0a3 100644 --- a/web/src/views_util.js +++ b/web/src/views_util.js @@ -3,9 +3,9 @@ import $ from "jquery"; import * as compose_recipient from "./compose_recipient"; import * as message_lists from "./message_lists"; import * as message_view_header from "./message_view_header"; +import * as message_viewport from "./message_viewport"; import * as narrow_state from "./narrow_state"; import * as narrow_title from "./narrow_title"; -import * as navigate from "./navigate"; import * as pm_list from "./pm_list"; import * as resize from "./resize"; import * as search from "./search"; @@ -71,5 +71,5 @@ export function hide(opts) { // This makes sure user lands on the selected message // and not always at the top of the narrow. - navigate.plan_scroll_to_selected(); + message_viewport.plan_scroll_to_selected(); }