Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left_sidebar: Show all other section channels on prefix match.
Aman Agrawalf14a5c2d1056
diff --git a/web/src/stream_list_sort.ts b/web/src/stream_list_sort.tsindex ef386915f7e..fe79b2fbbd5 100644--- a/web/src/stream_list_sort.ts+++ b/web/src/stream_list_sort.ts@@ -14,6 +14,8 @@ import * as util from "./util.ts";let first_render_completed = false;let current_sections: StreamListSection[] = [];let all_rows: number[] = [];+// Will normal section be visible if search_term is empty with "other" title?+let other_section_visible_without_search_term = false;// Because we need to check whether we are filtering inactive streams// in a loop over all streams to render the left sidebar, and the@@ -130,10 +132,15 @@ export function sort_groups(muted_streams: [],inactive_streams: [],};+ const NORMAL_SECTION_TITLE_WITH_OTHER_FOLDERS = $t({defaultMessage: "OTHER"});const show_all_channels = util.prefix_match({value: normal_section.section_title, search_term});const include_all_pinned_channels =show_all_channels || util.prefix_match({value: pinned_section.section_title, search_term});+ const search_term_prefix_matches_other_section_title =+ search_term &&+ other_section_visible_without_search_term &&+ util.prefix_match({value: NORMAL_SECTION_TITLE_WITH_OTHER_FOLDERS, search_term});const stream_id_to_name = (stream_id: number): string => sub_store.get(stream_id)!.name;// Use -, _, : and / as word separators apart from the default space character@@ -186,6 +193,19 @@ export function sort_groups(];}+ if (!show_all_channels && search_term_prefix_matches_other_section_title) {+ matching_stream_ids = [+ ...matching_stream_ids,+ ...all_subscribed_stream_ids.filter((stream_id) => {+ const is_pinned = sub_store.get(stream_id)!.pin_to_top;+ const is_in_folder =+ user_settings.web_left_sidebar_show_channel_folders &&+ sub_store.get(stream_id)!.folder_id !== null;+ return !is_pinned && !is_in_folder;+ }),+ ];+ }+for (const stream_id of matching_stream_ids) {const sub = sub_store.get(stream_id);assert(sub);@@ -251,9 +271,18 @@ export function sort_groups(pinned_section.streams.length > 0 ||pinned_section.muted_streams.length > 0 ||pinned_section.inactive_streams.length > 0 ||- folder_sections.size > 0+ folder_sections.size > 0 ||+ // To meet the user's expectation, we show "Other" as+ // section title if it matches the search term.+ search_term_prefix_matches_other_section_title) {- normal_section.section_title = $t({defaultMessage: "OTHER"});+ normal_section.section_title = NORMAL_SECTION_TITLE_WITH_OTHER_FOLDERS;++ if (search_term === "") {+ other_section_visible_without_search_term = true;+ }+ } else if (search_term === "") {+ other_section_visible_without_search_term = false;}// This needs to have the same ordering as the order they're displayed in the sidebar.diff --git a/web/tests/stream_list_sort.test.cjs b/web/tests/stream_list_sort.test.cjsindex 6222bfabdce..e7633f84c68 100644--- a/web/tests/stream_list_sort.test.cjs+++ b/web/tests/stream_list_sort.test.cjs@@ -370,6 +370,17 @@ test("basics", ({override}) => {// despite being order 1.expect_demoted_folder.id.toString(),]);++ // Only show other channels+ sorted_sections = sort_groups("other").sections;+ assert.deepEqual(sorted_sections.length, 2);+ assert.deepEqual(sorted_sections[0].id, "pinned-streams");+ assert.deepEqual(sorted_sections[0].streams, []);+ assert.deepEqual(sorted_sections[0].inactive_streams, []);+ assert.deepEqual(sorted_sections[1].section_title, "translated: OTHER");+ assert.deepEqual(sorted_sections[1].streams, [clarinet.stream_id]);+ assert.deepEqual(sorted_sections[1].muted_streams, []);+ assert.deepEqual(sorted_sections[1].inactive_streams, []);});test("current_section_id_for_stream", ({override}) => {