Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left_sidebar: Let current_section_id_for_stream return undefined.
Evy Kassireree877ebbc55d
diff --git a/web/src/stream_list.ts b/web/src/stream_list.tsindex 5b55e2e98b1..1a990ceb990 100644--- a/web/src/stream_list.ts+++ b/web/src/stream_list.ts@@ -696,7 +696,9 @@ export function refresh_pinned_or_unpinned_stream(sub: StreamSubscription): voidbuild_stream_sidebar_row(sub);update_streams_sidebar();const section_id = stream_list_sort.current_section_id_for_stream(sub.stream_id);- maybe_hide_topic_bracket(section_id);+ if (section_id !== undefined) {+ maybe_hide_topic_bracket(section_id);+ }// Only scroll pinned topics into view. If we're unpinning// a topic, we may be literally trying to get it out of@@ -967,7 +969,7 @@ function on_sidebar_channel_click(}const section_for_stream = stream_list_sort.current_section_id_for_stream(stream_id);- if (collapsed_sections.has(section_for_stream)) {+ if (section_for_stream !== undefined && collapsed_sections.has(section_for_stream)) {// In the event that user clicks on the channel in the left// sidebar when its folder is collapsed, which is only there// to click on if the user was already viewing that channel,diff --git a/web/src/stream_list_sort.ts b/web/src/stream_list_sort.tsindex e43b711c7a9..0d3458cfb80 100644--- a/web/src/stream_list_sort.ts+++ b/web/src/stream_list_sort.ts@@ -49,11 +49,11 @@ function current_section_ids_for_streams(): Map<number, StreamListSection> {return map;}-export function current_section_id_for_stream(stream_id: number): string {+// Will return undefined if the given stream isn't in the user's stream+// list (i.e. they're not subscribed to it).+export function current_section_id_for_stream(stream_id: number): string | undefined {// Warning: This function is O(n), so it should not be called in a loop.- const section = current_section_ids_for_streams().get(stream_id);- assert(section !== undefined);- return section.id;+ return current_section_ids_for_streams().get(stream_id)?.id;}function compare_function(a: number, b: number): number {diff --git a/web/src/stream_settings_ui.ts b/web/src/stream_settings_ui.tsindex c6efab51458..097d0efefbe 100644--- a/web/src/stream_settings_ui.ts+++ b/web/src/stream_settings_ui.ts@@ -261,7 +261,9 @@ export function update_channel_folder(sub: StreamSubscription, folder_id: numberstream_ui_updates.update_channel_folder_dropdown(sub);stream_list.build_stream_list(false);const section_id = stream_list_sort.current_section_id_for_stream(sub.stream_id);- stream_list.maybe_hide_topic_bracket(section_id);+ if (section_id !== undefined) {+ stream_list.maybe_hide_topic_bracket(section_id);+ }}export function reset_dropdown_set_to_archived_folder(folder_id: number): void {