From a43ea3efaab2d4cc8bd74a5622b859775bfd0faa Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 6 Oct 2023 18:00:10 -0700 Subject: [PATCH] pm_list: Cut import of topic_zoom. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit topic_zoom.is_zoomed_in() can’t be true in pm_list.zoom_in, because “more conversations” would not be visible in that state. And it can’t be true when pm_list.handle_narrow_activated calls pm_list.expand, because “more topics” would not be visible in an all-DM view. So the only non-inert call is via click_handlers; move it there. Signed-off-by: Anders Kaseorg --- web/src/click_handlers.js | 5 +++++ web/src/pm_list.js | 9 --------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/web/src/click_handlers.js b/web/src/click_handlers.js index c08c774ae8..8d7496ebc5 100644 --- a/web/src/click_handlers.js +++ b/web/src/click_handlers.js @@ -41,6 +41,7 @@ import * as starred_messages_ui from "./starred_messages_ui"; import * as stream_list from "./stream_list"; import * as stream_popover from "./stream_popover"; import * as topic_list from "./topic_list"; +import * as topic_zoom from "./topic_zoom"; import * as ui_util from "./ui_util"; import {parse_html} from "./ui_util"; import * as user_topics from "./user_topics"; @@ -729,6 +730,10 @@ export function initialize() { ); const scroll_position = $left_sidebar_scrollbar.scrollTop(); + if (topic_zoom.is_zoomed_in()) { + topic_zoom.zoom_out(); + } + // This next bit of logic is a bit subtle; this header // button scrolls to the top of the direct messages // section is uncollapsed but out of view; otherwise, we diff --git a/web/src/pm_list.js b/web/src/pm_list.js index 648e3569f6..e0c07bc432 100644 --- a/web/src/pm_list.js +++ b/web/src/pm_list.js @@ -5,7 +5,6 @@ import * as pm_list_data from "./pm_list_data"; import * as pm_list_dom from "./pm_list_dom"; import * as resize from "./resize"; import * as scroll_util from "./scroll_util"; -import * as topic_zoom from "./topic_zoom"; import * as ui_util from "./ui_util"; import * as vdom from "./vdom"; @@ -100,11 +99,6 @@ export function update_private_messages() { } export function expand() { - // Only one thing can be zoomed at a time. - if (topic_zoom.is_zoomed_in()) { - topic_zoom.zoom_out(); - } - private_messages_collapsed = false; $("#toggle_private_messages_section_icon").addClass("fa-caret-down"); @@ -193,9 +187,6 @@ export function toggle_private_messages_section() { function zoom_in() { zoomed = true; - if (topic_zoom.is_zoomed_in()) { - topic_zoom.zoom_out(); - } update_private_messages(); $(".private_messages_container").removeClass("zoom-out").addClass("zoom-in"); $("#streams_list").hide();