From 3bb771187aadb97f5770f24f5bd04df885942f8a Mon Sep 17 00:00:00 2001 From: filipriec Date: Mon, 24 Mar 2025 15:09:35 +0100 Subject: [PATCH] admin bug fixed, time for intro also --- client/src/ui/handlers/render.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/client/src/ui/handlers/render.rs b/client/src/ui/handlers/render.rs index 58a95af..b65729a 100644 --- a/client/src/ui/handlers/render.rs +++ b/client/src/ui/handlers/render.rs @@ -43,22 +43,23 @@ 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 for rendering + // Create temporary AdminPanelState for rendering let mut admin_state = AdminPanelState::new( - if app_state.profile_tree.profiles.is_empty() { - // Fallback if admin_profiles is empty - app_state.profile_tree.profiles - .iter() - .map(|p| p.name.clone()) - .collect() - } else { - app_state.profile_tree.profiles.iter().map(|p| p.name.clone()).collect() - } + app_state.profile_tree.profiles + .iter() + .map(|p| p.name.clone()) + .collect() ); - // Set the selected item + // Set the selected item - FIXED if !admin_state.profiles.is_empty() { - app_state.general.selected_item.min(admin_state.profiles.len().saturating_sub(1)); + let selected_index = std::cmp::min( + app_state.general.selected_item, + admin_state.profiles.len() - 1 + ); + admin_state.list_state.select(Some(selected_index)); } admin_state.render(