From dbc90ba2e57bee5a81d2ce7ebd967e42d54e1dc9 Mon Sep 17 00:00:00 2001 From: sanchi-t Date: Thu, 26 Sep 2024 11:50:41 +0530 Subject: [PATCH] stream_list: Prevent archived channels to show up in left sidebar. --- web/src/stream_list.ts | 5 +++-- web/src/stream_list_sort.ts | 3 +++ web/tests/stream_list_sort.test.js | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/web/src/stream_list.ts b/web/src/stream_list.ts index 2356fb794b..e1fd2ac8a5 100644 --- a/web/src/stream_list.ts +++ b/web/src/stream_list.ts @@ -227,7 +227,8 @@ export function create_initial_sidebar_rows(): void { // This code is slightly opaque, but it ends up building // up list items and attaching them to the "sub" data // structures that are kept in stream_data.js. - const subs = stream_data.subscribed_subs(); + let subs = stream_data.subscribed_subs(); + subs = subs.filter((sub) => !sub.is_archived); for (const sub of subs) { create_sidebar_row(sub); @@ -689,7 +690,7 @@ export function get_sidebar_stream_topic_info(filter: Filter): { return result; } - if (!stream_data.is_subscribed(stream_id)) { + if (!stream_data.is_subscribed(stream_id) || stream_data.is_stream_archived(stream_id)) { return result; } diff --git a/web/src/stream_list_sort.ts b/web/src/stream_list_sort.ts index 50c2e7f1d1..2b3bad124a 100644 --- a/web/src/stream_list_sort.ts +++ b/web/src/stream_list_sort.ts @@ -110,6 +110,9 @@ export function sort_groups(stream_ids: number[], search_term: string): StreamLi const sub = sub_store.get(stream_id); assert(sub); const pinned = sub.pin_to_top; + if (sub.is_archived) { + continue; + } if (pinned) { if (!sub.is_muted) { pinned_streams.push(stream_id); diff --git a/web/tests/stream_list_sort.test.js b/web/tests/stream_list_sort.test.js index 5da734e76b..305647c8a4 100644 --- a/web/tests/stream_list_sort.test.js +++ b/web/tests/stream_list_sort.test.js @@ -77,6 +77,13 @@ const muted_pinned = { pin_to_top: true, is_muted: true, }; +const archived = { + subscribed: true, + name: "archived channel", + stream_id: 9, + pin_to_top: true, + is_archived: true, +}; function sort_groups(query) { const streams = stream_data.subscribed_stream_ids(); @@ -112,6 +119,7 @@ test("basics", ({override_rewire}) => { stream_data.add_sub(stream_hyphen_underscore_slash_colon); stream_data.add_sub(muted_active); stream_data.add_sub(muted_pinned); + stream_data.add_sub(archived); override_rewire(stream_list_sort, "has_recent_activity", (sub) => sub.name !== "pneumonia");