get_subs_for_settings: Exclude archived streams from `All Streams` menu.

Don't display stream settings for archived channels.
This commit is contained in:
sanchi-t 2024-01-28 00:50:37 +05:30 committed by Tim Abbott
parent ca9ac293f3
commit a917215292
2 changed files with 7 additions and 3 deletions

View File

@ -223,14 +223,18 @@ export function validate_channels_settings_hash(hash: string): string {
const stream_id = Number.parseInt(section, 10); const stream_id = Number.parseInt(section, 10);
const sub = sub_store.get(stream_id); const sub = sub_store.get(stream_id);
// There are a few situations where we can't display stream settings: // 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) // 2. The stream ID is invalid. (sub=undefined)
// 3. The current user is a guest, and was unsubscribed from the stream // 3. The current user is a guest, and was unsubscribed from the stream
// stream in the current session. (In future sessions, the stream will // stream in the current session. (In future sessions, the stream will
// not be in sub_store). // not be in sub_store).
// //
// In all these cases we redirect the user to 'subscribed' tab. // 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(); return channels_settings_section_url();
} }

View File

@ -63,7 +63,7 @@ function get_subs_for_settings(subs: StreamSubscription[]): SettingsSubscription
// delegating, so that we can more efficiently compute subscriber counts // delegating, so that we can more efficiently compute subscriber counts
// (in bulk). If that plan appears to have been aborted, feel free to // (in bulk). If that plan appears to have been aborted, feel free to
// inline this. // 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[] { export function get_updated_unsorted_subs(): SettingsSubscription[] {