completely broken intro or admin

This commit is contained in:
filipriec
2025-03-23 15:35:57 +01:00
parent 4481560025
commit 87b07db26a
8 changed files with 21 additions and 19 deletions

View File

@@ -45,21 +45,20 @@ pub fn render_ui(
} else if app_state.ui.show_admin {
// Create temporary AdminPanelState for rendering
let mut admin_state = AdminPanelState::new(
if app_state.admin_profiles.is_empty() {
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.admin_profiles.clone()
app_state.profile_tree.profiles.iter().map(|p| p.name.clone()).collect()
}
);
// 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));
app_state.general.selected_item.min(admin_state.profiles.len().saturating_sub(1));
}
admin_state.render(

View File

@@ -30,11 +30,8 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
// Now create admin panel with profiles from app_state
if intro_state.selected_option == 1 {
app_state.ui.show_admin = true;
app_state.admin_profiles = app_state.profile_tree.profiles
.iter()
.map(|p| p.name.clone())
.collect();
app_state.admin_selected_item = 0;
app_state.general.selected_item = 0;
app_state.general.current_option = 0;
}
// Fetch table structure at startup (one-time)
@@ -95,7 +92,6 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
&mut app_state,
total_count,
&mut current_position,
&mut intro_state,
).await?;
app_state.current_position = current_position;