diff --git a/client/src/modes/general/dialog.rs b/client/src/modes/general/dialog.rs index ed309a5..eb861c5 100644 --- a/client/src/modes/general/dialog.rs +++ b/client/src/modes/general/dialog.rs @@ -93,8 +93,7 @@ pub async fn handle_dialog_event( match selected_index { 0 => { // "OK" button for RegisterSuccess app_state.hide_dialog(); - // Go back to intro after successful registration dialog - let message = register::back_to_main(register_state, app_state).await; + let message = register::back_to_login(register_state, app_state, buffer_state).await; return Some(Ok(EventOutcome::Ok(message))); } _ => { // Default for RegisterSuccess diff --git a/client/src/modes/handlers/event.rs b/client/src/modes/handlers/event.rs index a185cc4..a2663b7 100644 --- a/client/src/modes/handlers/event.rs +++ b/client/src/modes/handlers/event.rs @@ -196,7 +196,7 @@ impl EventHandler { UiContext::Register => { message = match index { 0 => register::save(register_state, &mut self.auth_client, app_state).await?, - 1 => register::back_to_main(register_state, app_state).await, + 1 => register::back_to_login(register_state, app_state, buffer_state).await, _ => "Invalid Login Option".to_string(), }; } diff --git a/client/src/tui/functions/common/login.rs b/client/src/tui/functions/common/login.rs index 98308c6..64e2dfe 100644 --- a/client/src/tui/functions/common/login.rs +++ b/client/src/tui/functions/common/login.rs @@ -99,8 +99,8 @@ pub async fn back_to_main( // Ensure dialog is hidden if revert is called app_state.hide_dialog(); // Uncomment if needed - // Navigation logic (currently disabled in original code) - let closed = buffer_state.close_active_buffer(); + // Navigation logic + buffer_state.close_active_buffer(); buffer_state.update_history(AppView::Intro); // Reset focus state diff --git a/client/src/tui/functions/common/register.rs b/client/src/tui/functions/common/register.rs index b7866e2..aa15936 100644 --- a/client/src/tui/functions/common/register.rs +++ b/client/src/tui/functions/common/register.rs @@ -1,14 +1,13 @@ // src/tui/functions/common/register.rs -use crate::{ - services::auth::AuthClient, - state::{ - pages::auth::RegisterState, - app::state::AppState, - pages::canvas_state::CanvasState, - }, - ui::handlers::context::DialogPurpose, +use crate::services::auth::AuthClient; +use crate::state::{ + pages::auth::RegisterState, + app::state::AppState, + pages::canvas_state::CanvasState, }; +use crate::ui::handlers::context::DialogPurpose; +use crate::state::app::buffer::{AppView, BufferState}; /// Attempts to register the user using the provided details via gRPC. /// Updates RegisterState and AppState on success or failure. @@ -131,9 +130,10 @@ pub async fn revert( } /// Clears the form and returns to the intro screen. -pub async fn back_to_main( +pub async fn back_to_login( register_state: &mut RegisterState, app_state: &mut AppState, + buffer_state: &mut BufferState, ) -> String { // Clear fields first let _ = revert(register_state, app_state).await; @@ -142,8 +142,8 @@ pub async fn back_to_main( app_state.hide_dialog(); // Navigation logic - app_state.ui.show_register = false; - app_state.ui.show_intro = true; + buffer_state.close_active_buffer(); + buffer_state.update_history(AppView::Login); // Reset focus state app_state.ui.focus_outside_canvas = false;