Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stream_list: Simplify zoom_in_topics and assert stream_id is defined.

Evy Kassirer4d7ee4248d20
diff --git a/web/src/stream_list.ts b/web/src/stream_list.ts
index 88e7164db62..a68291b8e08 100644
--- a/web/src/stream_list.ts
+++ b/web/src/stream_list.ts
@@ -69,13 +69,12 @@ export function is_zoomed_in(): boolean {
function zoom_in(): void {
const stream_id = topic_list.active_stream_id();
+ assert(stream_id !== undefined);
popovers.hide_all();
pm_list.close();
topic_list.zoom_in();
- zoom_in_topics({
- stream_id,
- });
+ zoom_in_topics(stream_id);
zoomed_in = true;
}
@@ -653,7 +652,7 @@ function stream_id_for_elt($elt: JQuery): number {
return Number.parseInt(stream_id_string, 10);
}
-export function zoom_in_topics(options: {stream_id: number | undefined}): void {
+export function zoom_in_topics(stream_id: number): void {
// This only does stream-related tasks related to zooming
// in to more topics, which is basically hiding all the
// other streams.
@@ -662,7 +661,6 @@ export function zoom_in_topics(options: {stream_id: number | undefined}): void {
$("#stream_filters li.narrow-filter").each(function () {
const $elt = $(this);
- const stream_id = options.stream_id;
if (stream_id_for_elt($elt) === stream_id) {
$elt.toggleClass("hide", false);
diff --git a/web/tests/stream_list.test.cjs b/web/tests/stream_list.test.cjs
index 5bc049d55dc..3c6a2916104 100644
--- a/web/tests/stream_list.test.cjs
+++ b/web/tests/stream_list.test.cjs
@@ -417,7 +417,7 @@ test_ui("zoom_in_and_zoom_out", ({mock_template}) => {
filter_topics_appended = true;
},
});
- stream_list.zoom_in_topics({stream_id: 42});
+ stream_list.zoom_in_topics(42);
assert.ok(!$stream_li1.hasClass("hide"));
assert.ok($stream_li2.hasClass("hide"));