left_sidebar: Add plus icon to channel section headers.

This commit is contained in:
Evy Kassirer
2025-06-24 23:02:09 -07:00
committed by Tim Abbott
parent 08fd7a30f9
commit 739debf7b4
5 changed files with 69 additions and 4 deletions

View File

@@ -262,10 +262,15 @@ export function create_initial_sidebar_rows(force_rerender = false): void {
}
}
export let stream_list_section_container_html = function (section: StreamListSection): string {
export let stream_list_section_container_html = function (
section: StreamListSection,
can_create_streams: boolean,
): string {
return render_stream_list_section_container({
id: section.id,
section_title: section.section_title,
show_plus_icon:
can_create_streams && !["pinned-streams", "dormant-streams"].includes(section.id),
});
};
@@ -301,8 +306,14 @@ export function build_stream_list(force_rerender: boolean): void {
clear_topics();
$("#stream_filters").empty();
const can_create_streams =
settings_data.user_can_create_private_streams() ||
settings_data.user_can_create_public_streams() ||
settings_data.user_can_create_web_public_streams();
for (const section of stream_groups.sections) {
$("#stream_filters").append($(stream_list_section_container_html(section)));
$("#stream_filters").append(
$(stream_list_section_container_html(section, can_create_streams)),
);
const is_empty = section.streams.length === 0 && section.muted_streams.length === 0;
$(`#stream-list-${section.id}-container`).toggleClass("no-display", is_empty);
@@ -1108,6 +1119,15 @@ export function set_event_handlers({
toggle_section_collapse($(this).closest(".stream-list-section-container"));
},
);
$("#streams_list").on(
"click",
".stream-list-section-container .add-stream-icon-container",
(e) => {
// To prevent toggling the header
e.stopPropagation();
},
);
}
export function searching(): boolean {