Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left_sidebar: Show all pinned channels on search prefix match.
Aman Agrawalbdc34d117da2
diff --git a/web/src/stream_list_sort.ts b/web/src/stream_list_sort.tsindex 728e8c92813..ef386915f7e 100644--- a/web/src/stream_list_sort.ts+++ b/web/src/stream_list_sort.ts@@ -132,6 +132,8 @@ export function sort_groups(};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 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@@ -175,6 +177,15 @@ export function sort_groups(const folder_sections = new Map<number, StreamListSection>();+ if (!show_all_channels && include_all_pinned_channels) {+ matching_stream_ids = [+ ...matching_stream_ids,+ ...all_subscribed_stream_ids.filter(+ (stream_id) => sub_store.get(stream_id)!.pin_to_top,+ ),+ ];+ }+for (const stream_id of matching_stream_ids) {const sub = sub_store.get(stream_id);assert(sub);diff --git a/web/tests/stream_list_sort.test.cjs b/web/tests/stream_list_sort.test.cjsindex eb2a8eb8902..6222bfabdce 100644--- a/web/tests/stream_list_sort.test.cjs+++ b/web/tests/stream_list_sort.test.cjs@@ -316,6 +316,16 @@ test("basics", ({override}) => {assert.deepEqual(sorted_sections[1].streams, [stream_hyphen_underscore_slash_colon.stream_id]);assert.deepEqual(sorted_sections[1].inactive_streams, []);+ // Only show pinned channels+ sorted_sections = sort_groups("pinned").sections;+ assert.deepEqual(sorted_sections.length, 2);+ assert.deepEqual(sorted_sections[0].id, "pinned-streams");+ assert.deepEqual(sorted_sections[0].streams, [scalene.stream_id]);+ assert.deepEqual(sorted_sections[0].inactive_streams, []);+ assert.deepEqual(sorted_sections[1].id, "normal-streams");+ assert.deepEqual(sorted_sections[1].inactive_streams, []);+ assert.deepEqual(sorted_sections[1].streams, []);+override(user_settings, "web_left_sidebar_show_channel_folders", true);sorted_sections = sort_groups("").sections;assert.deepEqual(sorted_sections.length, 5);