stream-list: Sort folder sections as per the folder order.

This commit is contained in:
Sahil Batra 2025-08-06 23:37:16 +05:30 committed by Tim Abbott
parent c127a0ae9f
commit 358f67a086
3 changed files with 6 additions and 2 deletions

View File

@ -50,6 +50,7 @@ export function add_channel_folder(): void {
rendered_description: "",
date_created: 0,
creator_id: people.my_current_user_id(),
order: id,
};
channel_folders.add(channel_folder);
},

View File

@ -158,6 +158,7 @@ export const channel_folder_schema = z.object({
creator_id: z.nullable(z.number()),
date_created: z.number(),
is_archived: z.boolean(),
order: z.number(),
});
export const navigation_view_schema = z.object({

View File

@ -107,6 +107,7 @@ export type StreamListSection = {
streams: number[];
muted_streams: number[];
inactive_streams: number[]; // Only used for folder sections
order?: number; // Only used for folder sections
};
type StreamListSortResult = {
@ -164,6 +165,7 @@ export function sort_groups(stream_ids: number[], search_term: string): StreamLi
streams: [],
muted_streams: [],
inactive_streams: [],
order: folder.order,
};
folder_sections.set(sub.folder_id, section);
}
@ -185,8 +187,8 @@ export function sort_groups(stream_ids: number[], search_term: string): StreamLi
}
}
const folder_sections_sorted = [...folder_sections.values()].sort((section_a, section_b) =>
util.strcmp(section_a.section_title, section_b.section_title),
const folder_sections_sorted = [...folder_sections.values()].sort(
(section_a, section_b) => section_a.order! - section_b.order!,
);
// This needs to have the same ordering as the order they're displayed in the sidebar.