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: Clean up component API.

Anders Kaseorgfba8c23dc08c
diff --git a/web/src/stream_list.js b/web/src/stream_list.js
index 12da9edf427..3576db28b39 100644
--- a/web/src/stream_list.js
+++ b/web/src/stream_list.js
@@ -681,7 +681,7 @@ export function initialize_stream_cursor() {
});
}
-export function initialize({narrow_on_stream_click}) {
+export function initialize({on_stream_click}) {
create_initial_sidebar_rows();
// We build the stream_list now. It may get re-built again very shortly
@@ -689,18 +689,17 @@ export function initialize({narrow_on_stream_click}) {
build_stream_list();
update_subscribe_to_more_streams_link();
initialize_stream_cursor();
- set_event_handlers({narrow_on_stream_click});
+ set_event_handlers({on_stream_click});
}
-export function set_event_handlers({narrow_on_stream_click}) {
+export function set_event_handlers({on_stream_click}) {
$("#stream_filters").on("click", "li .subscription_block", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
const stream_id = stream_id_for_elt($(e.target).parents("li"));
- const sub = sub_store.get(stream_id);
popovers.hide_all();
- narrow_on_stream_click("stream", sub.name, {trigger: "sidebar"});
+ on_stream_click(stream_id, "sidebar");
clear_and_hide_search();
@@ -754,15 +753,8 @@ export function set_event_handlers({narrow_on_stream_click}) {
return;
}
- const sub = sub_store.get(stream_id);
-
- if (sub === undefined) {
- blueslip.error("Unknown stream_id for search/enter", {stream_id});
- return;
- }
-
clear_and_hide_search();
- narrow_on_stream_click("stream", sub.name, {trigger: "sidebar enter key"});
+ on_stream_click(stream_id, "sidebar enter key");
}
keydown_util.handle({
diff --git a/web/src/ui_init.js b/web/src/ui_init.js
index a7ca9e7a411..b3b4645cdb9 100644
--- a/web/src/ui_init.js
+++ b/web/src/ui_init.js
@@ -654,7 +654,12 @@ export function initialize_everything() {
stream_settings_ui.initialize();
user_group_settings_ui.initialize();
top_left_corner.initialize();
- stream_list.initialize({narrow_on_stream_click: narrow.by});
+ stream_list.initialize({
+ on_stream_click(stream_id, trigger) {
+ const sub = sub_store.get(stream_id);
+ narrow.by("stream", sub.name, {trigger});
+ },
+ });
stream_list_sort.initialize();
condense.initialize();
spoilers.initialize();