Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
topic_zoom: Merge into stream_list.
Anders Kaseorg27991bd5b079
diff --git a/tools/test-js-with-node b/tools/test-js-with-nodeindex 8d4ab4630c8..b6d4a50e6dc 100755--- a/tools/test-js-with-node+++ b/tools/test-js-with-node@@ -234,7 +234,6 @@ EXEMPT_FILES = make_set("web/src/todo_widget.js","web/src/topic_list.js","web/src/topic_popover.js",- "web/src/topic_zoom.js","web/src/tutorial.js","web/src/types.ts","web/src/typing.js",diff --git a/web/src/click_handlers.js b/web/src/click_handlers.jsindex 8d7496ebc57..2c5d7c0cc43 100644--- a/web/src/click_handlers.js+++ b/web/src/click_handlers.js@@ -41,7 +41,6 @@ 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";@@ -730,8 +729,8 @@ export function initialize() {);const scroll_position = $left_sidebar_scrollbar.scrollTop();- if (topic_zoom.is_zoomed_in()) {- topic_zoom.zoom_out();+ if (stream_list.is_zoomed_in()) {+ stream_list.zoom_out();}// This next bit of logic is a bit subtle; this headerdiff --git a/web/src/hotkey.js b/web/src/hotkey.jsindex 6f55746ce0d..2a573eeeafc 100644--- a/web/src/hotkey.js+++ b/web/src/hotkey.js@@ -52,7 +52,6 @@ import * as stream_data from "./stream_data";import * as stream_list from "./stream_list";import * as stream_popover from "./stream_popover";import * as stream_settings_ui from "./stream_settings_ui";-import * as topic_zoom from "./topic_zoom";import * as unread_ops from "./unread_ops";import * as user_card_popover from "./user_card_popover";import * as user_group_popover from "./user_group_popover";@@ -349,8 +348,8 @@ export function process_escape_key(e) {return true;}- if (topic_zoom.is_zoomed_in()) {- topic_zoom.zoom_out();+ if (stream_list.is_zoomed_in()) {+ stream_list.zoom_out();return true;}diff --git a/web/src/stream_list.js b/web/src/stream_list.jsindex fdd290fcf3b..0755b30ec27 100644--- a/web/src/stream_list.js+++ b/web/src/stream_list.js@@ -23,14 +23,70 @@ import * as stream_data from "./stream_data";import * as stream_list_sort from "./stream_list_sort";import * as sub_store from "./sub_store";import * as topic_list from "./topic_list";-import * as topic_zoom from "./topic_zoom";import * as ui_util from "./ui_util";import * as unread from "./unread";+let pending_stream_list_rerender = false;+let zoomed_in = false;+export let stream_cursor;let has_scrolled = false;+export function is_zoomed_in() {+ return zoomed_in;+}++function zoom_in() {+ const stream_id = topic_list.active_stream_id();++ popovers.hide_all();+ pm_list.close();+ topic_list.zoom_in();+ zoom_in_topics({+ stream_id,+ });++ zoomed_in = true;+}++export function set_pending_stream_list_rerender(value) {+ pending_stream_list_rerender = value;+}++export function zoom_out() {+ if (pending_stream_list_rerender) {+ update_streams_sidebar(true);+ }+ const $stream_li = topic_list.get_stream_li();++ popovers.hide_all();+ topic_list.zoom_out();+ zoom_out_topics();++ if ($stream_li) {+ scroll_stream_into_view($stream_li);+ }++ zoomed_in = false;+}++export function clear_topics() {+ const $stream_li = topic_list.get_stream_li();++ topic_list.close();++ if (zoomed_in) {+ zoom_out_topics();++ if ($stream_li) {+ scroll_stream_into_view($stream_li);+ }+ }++ zoomed_in = false;+}+export function update_count_in_dom($stream_li,stream_counts,@@ -197,7 +253,7 @@ export function build_stream_list(force_rerender) {elems.push(sidebar_row.get_li());}- topic_zoom.clear_topics();+ clear_topics();$parent.empty();const any_pinned_streams =@@ -491,17 +547,17 @@ function set_stream_unread_count(}export function update_streams_sidebar(force_rerender) {- if (!force_rerender && topic_zoom.is_zoomed_in()) {+ if (!force_rerender && is_zoomed_in()) {// We do our best to update topics that are displayed// in case user zoomed in. Streams list will be updated,// once the user zooms out. This avoids user being zoomed out// when a new message causes streams to re-arrange.const filter = narrow_state.filter();update_stream_sidebar_for_narrow(filter);- topic_zoom.set_pending_stream_list_rerender(true);+ set_pending_stream_list_rerender(true);return;}- topic_zoom.set_pending_stream_list_rerender(false);+ set_pending_stream_list_rerender(false);build_stream_list(force_rerender);@@ -624,7 +680,7 @@ export function update_stream_sidebar_for_narrow(filter) {const stream_id = info.stream_id;if (!stream_id) {- topic_zoom.clear_topics();+ clear_topics();return undefined;}@@ -637,7 +693,7 @@ export function update_stream_sidebar_for_narrow(filter) {// stopped appearing from March 2018 until at least// April 2020, so if it appears again, something regressed.blueslip.error("No stream_li for subscribed stream", {stream_id});- topic_zoom.clear_topics();+ clear_topics();return undefined;}@@ -651,7 +707,7 @@ export function update_stream_sidebar_for_narrow(filter) {$stream_li.addClass("stream-expanded");if (stream_id !== topic_list.active_stream_id()) {- topic_zoom.clear_topics();+ clear_topics();}topic_list.rebuild($stream_li, stream_id);@@ -668,7 +724,7 @@ export function handle_narrow_activated(filter) {export function handle_message_view_deactivated() {deselect_stream_items();- topic_zoom.clear_topics();+ clear_topics();}function focus_stream_filter(e) {@@ -711,6 +767,20 @@ export function initialize({on_stream_click}) {update_subscribe_to_more_streams_link();initialize_stream_cursor();set_event_handlers({on_stream_click});++ $("#stream_filters").on("click", ".show-more-topics", (e) => {+ zoom_in();++ e.preventDefault();+ e.stopPropagation();+ });++ $(".show-all-streams").on("click", (e) => {+ zoom_out();++ e.preventDefault();+ e.stopPropagation();+ });}export function set_event_handlers({on_stream_click}) {diff --git a/web/src/topic_zoom.js b/web/src/topic_zoom.jsdeleted file mode 100644index 248c2032bf4..00000000000--- a/web/src/topic_zoom.js+++ /dev/null@@ -1,79 +0,0 @@-import $ from "jquery";--import * as pm_list from "./pm_list";-import * as popovers from "./popovers";-import * as stream_list from "./stream_list";-import * as topic_list from "./topic_list";--let pending_stream_list_rerender = false;-let zoomed_in = false;--export function is_zoomed_in() {- return zoomed_in;-}--function zoom_in() {- const stream_id = topic_list.active_stream_id();-- popovers.hide_all();- pm_list.close();- topic_list.zoom_in();- stream_list.zoom_in_topics({- stream_id,- });-- zoomed_in = true;-}--export function set_pending_stream_list_rerender(value) {- pending_stream_list_rerender = value;-}--export function zoom_out() {- if (pending_stream_list_rerender) {- stream_list.update_streams_sidebar(true);- }- const $stream_li = topic_list.get_stream_li();-- popovers.hide_all();- topic_list.zoom_out();- stream_list.zoom_out_topics();-- if ($stream_li) {- stream_list.scroll_stream_into_view($stream_li);- }-- zoomed_in = false;-}--export function clear_topics() {- const $stream_li = topic_list.get_stream_li();-- topic_list.close();-- if (zoomed_in) {- stream_list.zoom_out_topics();-- if ($stream_li) {- stream_list.scroll_stream_into_view($stream_li);- }- }-- zoomed_in = false;-}--export function initialize() {- $("#stream_filters").on("click", ".show-more-topics", (e) => {- zoom_in();-- e.preventDefault();- e.stopPropagation();- });-- $(".show-all-streams").on("click", (e) => {- zoom_out();-- e.preventDefault();- e.stopPropagation();- });-}diff --git a/web/src/ui_init.js b/web/src/ui_init.jsindex a645cddacbe..d9070ab6da3 100644--- a/web/src/ui_init.js+++ b/web/src/ui_init.js@@ -124,7 +124,6 @@ import * as timerender from "./timerender";import * as tippyjs from "./tippyjs";import * as topic_list from "./topic_list";import * as topic_popover from "./topic_popover";-import * as topic_zoom from "./topic_zoom";import * as transmit from "./transmit";import * as tutorial from "./tutorial";import * as typeahead_helper from "./typeahead_helper";@@ -713,7 +712,6 @@ export function initialize_everything() {);},});- topic_zoom.initialize();drafts.initialize();drafts_overlay_ui.initialize();sent_messages.initialize();