From a91721529212220d40a44372b7ec3db204098811 Mon Sep 17 00:00:00 2001 From: sanchi-t Date: Sun, 28 Jan 2024 00:50:37 +0530 Subject: [PATCH] get_subs_for_settings: Exclude archived streams from `All Streams` menu. Don't display stream settings for archived channels. --- web/src/hash_util.ts | 8 ++++++-- web/src/stream_settings_data.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts index d3c6a0ff1a..ccf554f4e1 100644 --- a/web/src/hash_util.ts +++ b/web/src/hash_util.ts @@ -223,14 +223,18 @@ export function validate_channels_settings_hash(hash: string): string { const stream_id = Number.parseInt(section, 10); const sub = sub_store.get(stream_id); // There are a few situations where we can't display stream settings: - // 1. This is a stream that's been archived. (sub=undefined) + // 1. This is a stream that's been archived. (sub.is_archived=true) // 2. The stream ID is invalid. (sub=undefined) // 3. The current user is a guest, and was unsubscribed from the stream // stream in the current session. (In future sessions, the stream will // not be in sub_store). // // In all these cases we redirect the user to 'subscribed' tab. - if (sub === undefined || (page_params.is_guest && !stream_data.is_subscribed(stream_id))) { + if ( + sub === undefined || + sub.is_archived || + (page_params.is_guest && !stream_data.is_subscribed(stream_id)) + ) { return channels_settings_section_url(); } diff --git a/web/src/stream_settings_data.ts b/web/src/stream_settings_data.ts index 660bf63a86..d7cb664a8a 100644 --- a/web/src/stream_settings_data.ts +++ b/web/src/stream_settings_data.ts @@ -63,7 +63,7 @@ function get_subs_for_settings(subs: StreamSubscription[]): SettingsSubscription // delegating, so that we can more efficiently compute subscriber counts // (in bulk). If that plan appears to have been aborted, feel free to // inline this. - return subs.map((sub) => get_sub_for_settings(sub)); + return subs.filter((sub) => !sub.is_archived).map((sub) => get_sub_for_settings(sub)); } export function get_updated_unsorted_subs(): SettingsSubscription[] {