diff --git a/client/src/modes/canvas/common.rs b/client/src/modes/canvas/common.rs index 1ed4226..bd823c6 100644 --- a/client/src/modes/canvas/common.rs +++ b/client/src/modes/canvas/common.rs @@ -43,7 +43,7 @@ pub async fn handle_core_action( }, "save_and_quit" => { let message = if app_state.ui.show_login { - login_save(auth_state, grpc_client).await? + login_save(auth_state, auth_client, app_state).await? } else { form_save( form_state, diff --git a/client/src/modes/handlers/event.rs b/client/src/modes/handlers/event.rs index 5889f68..5056c68 100644 --- a/client/src/modes/handlers/event.rs +++ b/client/src/modes/handlers/event.rs @@ -5,6 +5,7 @@ use crate::tui::terminal::{ core::TerminalCore, }; use crate::services::grpc_client::GrpcClient; +use crate::services::auth::AuthClient; use crate::tui::functions::common::commands::CommandHandler; use crate::config::binds::config::Config; use crate::state::pages::form::FormState; @@ -27,11 +28,12 @@ pub struct EventHandler { pub ideal_cursor_column: usize, pub key_sequence_tracker: KeySequenceTracker, pub auth_state: AuthState, + pub auth_client: AuthClient, } impl EventHandler { - pub fn new() -> Self { - EventHandler { + pub async fn new() -> Result> { + Ok(EventHandler { command_mode: false, command_input: String::new(), command_message: String::new(), @@ -40,7 +42,8 @@ impl EventHandler { ideal_cursor_column: 0, key_sequence_tracker: KeySequenceTracker::new(800), auth_state: AuthState::new(), - } + auth_client: AuthClient::new().await?, + }) } pub async fn handle_event( @@ -133,6 +136,7 @@ impl EventHandler { form_state, &mut self.auth_state, grpc_client, + &mut self.auth_client, terminal, app_state, current_position, @@ -194,6 +198,7 @@ impl EventHandler { form_state, &mut self.auth_state, grpc_client, + &mut self.auth_client, terminal, app_state, current_position, diff --git a/client/src/ui/handlers/ui.rs b/client/src/ui/handlers/ui.rs index c026687..9a331f1 100644 --- a/client/src/ui/handlers/ui.rs +++ b/client/src/ui/handlers/ui.rs @@ -33,7 +33,7 @@ pub async fn run_ui() -> Result<(), Box> { let mut form_state = FormState::new(column_names); // The rest of your UI initialization remains the same - let mut event_handler = EventHandler::new(); + let mut event_handler = EventHandler::new().await?; let event_reader = EventReader::new(); // Fetch the total count of Adresar entries