Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
pointer: Move planned scroll logic to navigate.js.
Tim Abbott5321e8792ddb
diff --git a/static/js/navigate.js b/static/js/navigate.jsindex c31d15a63ff..cb1c8ca618d 100644--- a/static/js/navigate.js+++ b/static/js/navigate.js@@ -128,13 +128,17 @@ exports.scroll_to_selected = function () {}};+let scroll_to_selected_planned = false;+exports.plan_scroll_to_selected = function () {+ scroll_to_selected_planned = true;+};exports.maybe_scroll_to_selected = function () {- // If we have been previously instructed to re-center to the- // selected message, then do so- if (pointer.recenter_pointer_on_display) {+ // If we have made a plan to scroll to the selected message but+ // deferred doing so, do so here.+ if (scroll_to_selected_planned) {exports.scroll_to_selected();- pointer.set_recenter_pointer_on_display(false);+ scroll_to_selected_planned = false;}};diff --git a/static/js/pointer.js b/static/js/pointer.jsindex 7e2565f1be9..a5fbe98ac6d 100644--- a/static/js/pointer.js+++ b/static/js/pointer.js@@ -1,11 +1,6 @@// See https://zulip.readthedocs.io/en/latest/subsystems/pointer.html for notes on// how this system is designed.-exports.recenter_pointer_on_display = false;-exports.set_recenter_pointer_on_display = function (value) {- exports.recenter_pointer_on_display = value;-};-exports.initialize = function initialize() {$(document).on('message_selected.zulip', function (event) {if (event.id === -1) {diff --git a/static/js/stream_muting.js b/static/js/stream_muting.jsindex 54e1beeb949..e833093e51b 100644--- a/static/js/stream_muting.js+++ b/static/js/stream_muting.js@@ -31,10 +31,12 @@ exports.update_is_muted = function (sub, value) {}}- // In case we added messages to what's visible in the home view, we need to re-scroll to- // make sure the pointer is still visible. We don't want the auto-scroll handler to move- // our pointer to the old scroll location before we have a chance to update it.- pointer.set_recenter_pointer_on_display(true);+ // In case we added messages to what's visible in the home+ // view, we need to re-scroll to make sure the pointer is+ // still visible. We don't want the auto-scroll handler to+ // move our pointer to the old scroll location before we have+ // a chance to update it.+ navigate.plan_scroll_to_selected();message_scroll.suppress_selection_update_on_next_scroll();if (!home_msg_list.empty()) {