still one error missing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// src/client/ui/handlers/ui.rs
|
||||
// src/ui/handlers/ui.rs
|
||||
|
||||
use crate::tui::terminal::TerminalCore;
|
||||
use crate::tui::terminal::GrpcClient;
|
||||
@@ -19,10 +19,22 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut command_handler = CommandHandler::new();
|
||||
let theme = Theme::from_str(&config.colors.theme);
|
||||
let mut intro_state = IntroState::new();
|
||||
let admin_panel_state = AdminPanelState::new();
|
||||
|
||||
// Initialize app_state first
|
||||
let mut app_state = AppState::new()?;
|
||||
|
||||
// Fetch profile tree and table structure
|
||||
let profile_tree = grpc_client.get_profile_tree().await?;
|
||||
app_state.profile_tree = profile_tree;
|
||||
|
||||
// Now create admin panel with profiles from app_state
|
||||
let profiles = app_state.profile_tree.profiles
|
||||
.iter()
|
||||
.map(|p| p.name.clone())
|
||||
.collect();
|
||||
let admin_panel_state = AdminPanelState::new(profiles);
|
||||
|
||||
// Fetch table structure at startup (one-time)
|
||||
// TODO: Later, consider implementing a live update for table structure changes.
|
||||
let table_structure = grpc_client.get_table_structure().await?;
|
||||
|
||||
// Extract the column names from the response
|
||||
@@ -35,13 +47,9 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Initialize FormState with dynamic fields
|
||||
let mut form_state = FormState::new(column_names);
|
||||
|
||||
// Fetch profile tree and table structure
|
||||
let profile_tree = grpc_client.get_profile_tree().await?;
|
||||
// The rest of your UI initialization remains the same
|
||||
let mut event_handler = EventHandler::new();
|
||||
let event_reader = EventReader::new();
|
||||
let mut app_state = AppState::new()?;
|
||||
app_state.profile_tree = profile_tree;
|
||||
|
||||
// Fetch the total count of Adresar entries
|
||||
let total_count = grpc_client.get_adresar_count().await?;
|
||||
@@ -100,7 +108,6 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
};
|
||||
form_state.current_cursor_pos = event_handler.ideal_cursor_column.min(max_cursor_pos);
|
||||
|
||||
|
||||
// Ensure position never exceeds total_count + 1
|
||||
if app_state.current_position > total_count + 1 {
|
||||
app_state.current_position = total_count + 1;
|
||||
|
||||
Reference in New Issue
Block a user