diff --git a/web/src/channel_folders_ui.ts b/web/src/channel_folders_ui.ts index 25aef221ad..e466b60fb1 100644 --- a/web/src/channel_folders_ui.ts +++ b/web/src/channel_folders_ui.ts @@ -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); }, diff --git a/web/src/state_data.ts b/web/src/state_data.ts index f6dae0aff1..2c8ae7f736 100644 --- a/web/src/state_data.ts +++ b/web/src/state_data.ts @@ -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({ diff --git a/web/src/stream_list_sort.ts b/web/src/stream_list_sort.ts index 4de0c2a8ed..e43b711c7a 100644 --- a/web/src/stream_list_sort.ts +++ b/web/src/stream_list_sort.ts @@ -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.