Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Simplify actively_scrolling data flow.
Tim Abbott0f01eae65559
diff --git a/web/src/hashchange.js b/web/src/hashchange.jsindex cc2e2688eba..ca0faac0c33 100644--- a/web/src/hashchange.js+++ b/web/src/hashchange.js@@ -12,7 +12,6 @@ import * as inbox_ui from "./inbox_ui";import * as inbox_util from "./inbox_util";import * as info_overlay from "./info_overlay";import * as message_lists from "./message_lists";-import * as message_scroll from "./message_scroll";import * as message_viewport from "./message_viewport";import * as modals from "./modals";import * as narrow from "./narrow";@@ -54,8 +53,7 @@ function maybe_hide_inbox() {function show_all_message_view() {const coming_from_recent_view = maybe_hide_recent_view();const coming_from_inbox = maybe_hide_inbox();- const is_actively_scrolling = message_scroll.is_actively_scrolling();- narrow.deactivate(coming_from_recent_view || coming_from_inbox, is_actively_scrolling);+ narrow.deactivate(coming_from_recent_view || coming_from_inbox);// We need to maybe scroll to the selected message// once we have the proper viewport set upsetTimeout(message_viewport.maybe_scroll_to_selected, 0);diff --git a/web/src/message_scroll.js b/web/src/message_scroll.jsindex 428cabd5bcc..040f0ebcc81 100644--- a/web/src/message_scroll.js+++ b/web/src/message_scroll.js@@ -11,8 +11,6 @@ import * as unread from "./unread";import * as unread_ops from "./unread_ops";import * as unread_ui from "./unread_ui";-let actively_scrolling = false;-let hide_scroll_to_bottom_timer;export function hide_scroll_to_bottom() {const $show_scroll_to_bottom_button = $("#scroll-to-bottom-button-container");@@ -57,12 +55,8 @@ $(document).on("keydown", (e) => {$("#scroll-to-bottom-button-container").removeClass("show");});-export function is_actively_scrolling() {- return actively_scrolling;-}-export function scroll_finished() {- actively_scrolling = false;+ message_scroll_state.set_actively_scrolling(false);message_lists.current.view.update_sticky_recipient_headers();hide_scroll_to_bottom();@@ -106,7 +100,7 @@ export function scroll_finished() {let scroll_timer;function scroll_finish() {- actively_scrolling = true;+ message_scroll_state.set_actively_scrolling(true);// Don't present the "scroll to bottom" widget if the current// scroll was triggered by the keyboard.diff --git a/web/src/message_scroll_state.ts b/web/src/message_scroll_state.tsindex c59149c7622..9828f0bea6a 100644--- a/web/src/message_scroll_state.ts+++ b/web/src/message_scroll_state.ts@@ -13,3 +13,10 @@ export let keyboard_triggered_current_scroll = false;export function set_keyboard_triggered_current_scroll(value: boolean): void {keyboard_triggered_current_scroll = value;}++// Whether a scroll is currently occurring.+export let actively_scrolling = false;++export function set_actively_scrolling(value: boolean): void {+ actively_scrolling = value;+}diff --git a/web/src/narrow.js b/web/src/narrow.jsindex e17e8b547e7..6f8c30ec745 100644--- a/web/src/narrow.js+++ b/web/src/narrow.js@@ -28,6 +28,7 @@ import * as message_helper from "./message_helper";import * as message_list from "./message_list";import {MessageListData} from "./message_list_data";import * as message_lists from "./message_lists";+import * as message_scroll_state from "./message_scroll_state";import * as message_store from "./message_store";import * as message_view_header from "./message_view_header";import * as message_viewport from "./message_viewport";@@ -970,7 +971,7 @@ function handle_post_narrow_deactivate_processes(msg_list) {message_feed_top_notices.update_top_of_narrow_notices(msg_list);}-export function deactivate(message_feed_previously_hidden = false, is_actively_scrolling = false) {+export function deactivate(message_feed_previously_hidden = false) {// NOTE: Never call this function independently,// always use browser_history.go_to_location("#all_messages") to// activate All message narrow.@@ -994,7 +995,7 @@ export function deactivate(message_feed_previously_hidden = false, is_actively_s}blueslip.debug("Unnarrowed");- if (is_actively_scrolling) {+ if (message_scroll_state.actively_scrolling) {// There is no way to intercept in-flight scroll events, and they will// cause you to end up in the wrong place if you are actively scrolling// on an unnarrow. Wait a bit and try again once the scrolling is likely over.