left_sidebar: Let current_section_id_for_stream return undefined.

Fixes this issue from Sentry:
https://zulip.sentry.io/issues/6778533249/events/9e2a25e419bc4dc2b7a207c5a482f943/?project=4504556882821120
This commit is contained in:
Evy Kassirer
2025-08-07 17:57:45 -07:00
committed by Tim Abbott
parent c9fd9ade11
commit ee877ebbc5
3 changed files with 11 additions and 7 deletions

View File

@@ -696,7 +696,9 @@ export function refresh_pinned_or_unpinned_stream(sub: StreamSubscription): void
build_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,

View File

@@ -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 {

View File

@@ -261,7 +261,9 @@ export function update_channel_folder(sub: StreamSubscription, folder_id: number
stream_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 {