Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left_sidebar: Refactor display left sidebar for stream list filter.
Pratik Chandac071d952e180
diff --git a/web/src/sidebar_ui.ts b/web/src/sidebar_ui.tsindex a07e8e0458c..bca270e50de 100644--- a/web/src/sidebar_ui.ts+++ b/web/src/sidebar_ui.ts@@ -14,6 +14,7 @@ import * as message_lists from "./message_lists.ts";import * as message_viewport from "./message_viewport.ts";import {page_params} from "./page_params.ts";import * as popover_menus from "./popover_menus.ts";+import * as popovers from "./popovers.ts";import * as rendered_markdown from "./rendered_markdown.ts";import * as resize from "./resize.ts";import * as settings_config from "./settings_config.ts";@@ -73,6 +74,21 @@ export function show_streamlist_sidebar(): void {left_sidebar_expanded_as_overlay = true;}+// We use this to display left sidebar without setting+// toggle status+export function show_left_sidebar(): void {+ if (+ // Check if left column is a overlay and is not visible.+ $("#streamlist-toggle").is(":visible") &&+ !left_sidebar_expanded_as_overlay+ ) {+ popovers.hide_all();+ show_streamlist_sidebar();+ } else if (!left_sidebar_expanded_as_overlay) {+ $("body").removeClass("hide-left-sidebar");+ }+}+export function hide_streamlist_sidebar(): void {$(".app-main .column-left").removeClass("expanded");left_sidebar_expanded_as_overlay = false;diff --git a/web/src/stream_list.ts b/web/src/stream_list.tsindex 32ce5ed3492..1355226defc 100644--- a/web/src/stream_list.ts+++ b/web/src/stream_list.ts@@ -1048,16 +1048,7 @@ export function initiate_search(): void {const $filter = $(".stream-list-filter").expectOne();- if (- // Check if left column is a overlay and is not visible.- $("#streamlist-toggle").is(":visible") &&- !sidebar_ui.left_sidebar_expanded_as_overlay- ) {- popovers.hide_all();- sidebar_ui.show_streamlist_sidebar();- } else if (!sidebar_ui.left_sidebar_expanded_as_overlay) {- $("body").removeClass("hide-left-sidebar");- }+ sidebar_ui.show_left_sidebar();$filter.trigger("focus");stream_cursor.reset();diff --git a/web/tests/stream_search.test.cjs b/web/tests/stream_search.test.cjsindex e5f70db96e8..023afd4e536 100644--- a/web/tests/stream_search.test.cjs+++ b/web/tests/stream_search.test.cjs@@ -62,6 +62,7 @@ function clear_search_input() {run_test("basics", ({override, override_rewire}) => {override(popovers, "hide_all", noop);+ override(sidebar_ui, "show_left_sidebar", noop);const $input = $(".stream-list-filter");const $section = $(".stream_search_section");@@ -179,8 +180,8 @@ run_test("expanding_sidebar", ({override, override_rewire}) => {events.push("popovers.hide_all");});- override(sidebar_ui, "show_streamlist_sidebar", () => {- events.push("sidebar_ui.show_streamlist_sidebar");+ override(sidebar_ui, "show_left_sidebar", () => {+ events.push("popovers.hide_all", "sidebar_ui.show_streamlist_sidebar");});$("#streamlist-toggle").show();