Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
topic_list: Clean up component API.
Anders Kaseorg9d8c6f91866d
diff --git a/web/src/topic_list.js b/web/src/topic_list.jsindex b359943f85d..ad7fdc21473 100644--- a/web/src/topic_list.js+++ b/web/src/topic_list.js@@ -10,7 +10,6 @@ import * as popover_menus from "./popover_menus";import * as scroll_util from "./scroll_util";import * as stream_topic_history from "./stream_topic_history";import * as stream_topic_history_util from "./stream_topic_history_util";-import * as sub_store from "./sub_store";import * as topic_list_data from "./topic_list_data";import * as vdom from "./vdom";@@ -305,7 +304,7 @@ export function get_topic_search_term() {return $filter.val().trim();}-export function initialize({narrow_on_topic_click}) {+export function initialize({on_topic_click}) {$("#stream_filters").on("click", ".topic-box", (e) => {if (e.metaKey || e.ctrlKey) {return;@@ -314,21 +313,10 @@ export function initialize({narrow_on_topic_click}) {return;}- // In a more componentized world, we would delegate some- // of this stuff back up to our parents.-const $stream_row = $(e.target).parents(".narrow-filter");const stream_id = Number.parseInt($stream_row.attr("data-stream-id"), 10);- const sub = sub_store.get(stream_id);const topic = $(e.target).parents("li").attr("data-topic-name");-- narrow_on_topic_click(- [- {operator: "stream", operand: sub.name},- {operator: "topic", operand: topic},- ],- {trigger: "sidebar"},- );+ on_topic_click(stream_id, topic);e.preventDefault();});diff --git a/web/src/ui_init.js b/web/src/ui_init.jsindex d0cbd97f62c..a7ca9e7a411 100644--- a/web/src/ui_init.js+++ b/web/src/ui_init.js@@ -99,6 +99,7 @@ import * as stream_edit_subscribers from "./stream_edit_subscribers";import * as stream_list from "./stream_list";import * as stream_list_sort from "./stream_list_sort";import * as stream_settings_ui from "./stream_settings_ui";+import * as sub_store from "./sub_store";import * as timerender from "./timerender";import * as tippyjs from "./tippyjs";import * as top_left_corner from "./top_left_corner";@@ -705,7 +706,18 @@ export function initialize_everything() {activity.initialize();emoji_picker.initialize();pm_list.initialize();- topic_list.initialize({narrow_on_topic_click: narrow.activate});+ topic_list.initialize({+ on_topic_click(stream_id, topic) {+ const sub = sub_store.get(stream_id);+ narrow.activate(+ [+ {operator: "stream", operand: sub.name},+ {operator: "topic", operand: topic},+ ],+ {trigger: "sidebar"},+ );+ },+ });topic_zoom.initialize();drafts.initialize();sent_messages.initialize();