From c6c6c5ed819517d2f7579e3febcbdb0bb75d9826 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sun, 23 Mar 2025 12:59:36 +0100 Subject: [PATCH] restored rendering --- client/src/ui/handlers/render.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/client/src/ui/handlers/render.rs b/client/src/ui/handlers/render.rs index 918dadc..ed7eac0 100644 --- a/client/src/ui/handlers/render.rs +++ b/client/src/ui/handlers/render.rs @@ -43,15 +43,30 @@ pub fn render_ui( if app_state.ui.show_intro { intro_state.render(f, main_content_area, theme); } else if app_state.ui.show_admin { - // Create temporary AdminPanelState using app_state data - let mut admin_state = AdminPanelState::new(app_state.admin_profiles.clone()); - admin_state.list_state.select(Some(app_state.admin_selected_item)); - + // Create temporary AdminPanelState for rendering + let mut admin_state = AdminPanelState::new( + if app_state.admin_profiles.is_empty() { + // Fallback if admin_profiles is empty + app_state.profile_tree.profiles + .iter() + .map(|p| p.name.clone()) + .collect() + } else { + app_state.admin_profiles.clone() + } + ); + + // Set the selected item + if !admin_state.profiles.is_empty() { + let safe_index = app_state.admin_selected_item.min(admin_state.profiles.len() - 1); + admin_state.list_state.select(Some(safe_index)); + } + admin_state.render( f, main_content_area, theme, - &app_state.profile_tree, + &app_state.profile_tree, &app_state.selected_profile, ); } else {