mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
stream_list: Break dependency on narrow.js.
This commit is contained in:
@@ -12,7 +12,6 @@ import * as hash_util from "./hash_util";
|
||||
import {$t} from "./i18n";
|
||||
import * as keydown_util from "./keydown_util";
|
||||
import {ListCursor} from "./list_cursor";
|
||||
import * as narrow from "./narrow";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as pm_list from "./pm_list";
|
||||
import * as popovers from "./popovers";
|
||||
@@ -682,7 +681,7 @@ export function initialize_stream_cursor() {
|
||||
});
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
export function initialize({narrow_on_stream_click}) {
|
||||
create_initial_sidebar_rows();
|
||||
|
||||
// We build the stream_list now. It may get re-built again very shortly
|
||||
@@ -690,10 +689,10 @@ export function initialize() {
|
||||
build_stream_list();
|
||||
update_subscribe_to_more_streams_link();
|
||||
initialize_stream_cursor();
|
||||
set_event_handlers();
|
||||
set_event_handlers({narrow_on_stream_click});
|
||||
}
|
||||
|
||||
export function set_event_handlers() {
|
||||
export function set_event_handlers({narrow_on_stream_click}) {
|
||||
$("#stream_filters").on("click", "li .subscription_block", (e) => {
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
return;
|
||||
@@ -701,7 +700,7 @@ export function set_event_handlers() {
|
||||
const stream_id = stream_id_for_elt($(e.target).parents("li"));
|
||||
const sub = sub_store.get(stream_id);
|
||||
popovers.hide_all();
|
||||
narrow.by("stream", sub.name, {trigger: "sidebar"});
|
||||
narrow_on_stream_click("stream", sub.name, {trigger: "sidebar"});
|
||||
|
||||
clear_and_hide_search();
|
||||
|
||||
@@ -763,7 +762,7 @@ export function set_event_handlers() {
|
||||
}
|
||||
|
||||
clear_and_hide_search();
|
||||
narrow.by("stream", sub.name, {trigger: "sidebar enter key"});
|
||||
narrow_on_stream_click("stream", sub.name, {trigger: "sidebar enter key"});
|
||||
}
|
||||
|
||||
keydown_util.handle({
|
||||
|
||||
@@ -652,7 +652,7 @@ export function initialize_everything() {
|
||||
stream_settings_ui.initialize();
|
||||
user_group_settings_ui.initialize();
|
||||
top_left_corner.initialize();
|
||||
stream_list.initialize();
|
||||
stream_list.initialize({narrow_on_stream_click: narrow.by});
|
||||
stream_list_sort.initialize();
|
||||
condense.initialize();
|
||||
spoilers.initialize();
|
||||
|
||||
@@ -462,14 +462,14 @@ test_ui("narrowing", ({mock_template}) => {
|
||||
});
|
||||
|
||||
test_ui("focusout_user_filter", () => {
|
||||
stream_list.set_event_handlers();
|
||||
stream_list.set_event_handlers({narrow_on_stream_click() {}});
|
||||
const e = {};
|
||||
const click_handler = $(".stream-list-filter").get_on_handler("focusout");
|
||||
click_handler(e);
|
||||
});
|
||||
|
||||
test_ui("focus_user_filter", () => {
|
||||
stream_list.set_event_handlers();
|
||||
stream_list.set_event_handlers({narrow_on_stream_click() {}});
|
||||
|
||||
initialize_stream_data();
|
||||
stream_list.build_stream_list();
|
||||
|
||||
Reference in New Issue
Block a user