left_sidebar: Hide stream section separator when there is only one.

Showing section separators in the left sidebar ("Pinned streams",
"Active streams", etc.) is unnecessary when there is only one section,
and can feel confusing. We should show the separators only when there
is more than one section present.

Fixes #22843.
This commit is contained in:
Rixant Rokaha
2022-09-04 16:37:13 +00:00
committed by Tim Abbott
parent 72b5af2260
commit dd39a9747d
2 changed files with 10 additions and 11 deletions

View File

@@ -606,12 +606,8 @@ test_ui("separators_only_pinned_and_dormant", ({override_rewire, mock_template})
assert.ok(inactive_subheader_flag);
});
test_ui("separators_only_pinned", ({mock_template}) => {
test_ui("separators_only_pinned", () => {
// Test only pinned streams
create_stream_subheader({mock_template});
pinned_subheader_flag = false;
// Get coverage on early-exit.
stream_list.build_stream_list();
@@ -640,16 +636,14 @@ test_ui("separators_only_pinned", ({mock_template}) => {
};
stream_list.build_stream_list();
const $pinned_subheader = $("<pinned-subheader-stub>");
const expected_elems = [
$pinned_subheader.html(), // pinned
// no section sub-header since there is only one section
$("<devel-sidebar-row-stub>"),
$("<Rome-sidebar-row-stub>"),
// no separator at the end as no stream follows
];
assert.deepEqual(appended_elems, expected_elems);
assert.ok(pinned_subheader_flag);
});
test_ui("rename_stream", ({mock_template}) => {

View File

@@ -145,8 +145,13 @@ export function build_stream_list(force_rerender) {
const any_pinned_streams = stream_groups.pinned_streams.length > 0;
const any_normal_streams = stream_groups.normal_streams.length > 0;
const any_dormant_streams = stream_groups.dormant_streams.length > 0;
const need_section_subheaders =
(any_pinned_streams ? 1 : 0) +
(any_normal_streams ? 1 : 0) +
(any_dormant_streams ? 1 : 0) >=
2;
if (any_pinned_streams) {
if (any_pinned_streams && need_section_subheaders) {
elems.push(
render_stream_subheader({
subheader_name: $t({
@@ -164,7 +169,7 @@ export function build_stream_list(force_rerender) {
add_sidebar_li(stream_id);
}
if (any_normal_streams) {
if (any_normal_streams && need_section_subheaders) {
elems.push(
render_stream_subheader({
subheader_name: $t({
@@ -182,7 +187,7 @@ export function build_stream_list(force_rerender) {
add_sidebar_li(stream_id);
}
if (any_dormant_streams) {
if (any_dormant_streams && need_section_subheaders) {
elems.push(
render_stream_subheader({
subheader_name: $t({