buffer logic going hard, we are killing buffers from login and register now

This commit is contained in:
filipriec
2025-04-15 18:56:11 +02:00
parent e8b585dc07
commit 921059bed8
4 changed files with 15 additions and 16 deletions

View File

@@ -93,8 +93,7 @@ pub async fn handle_dialog_event(
match selected_index { match selected_index {
0 => { // "OK" button for RegisterSuccess 0 => { // "OK" button for RegisterSuccess
app_state.hide_dialog(); app_state.hide_dialog();
// Go back to intro after successful registration dialog let message = register::back_to_login(register_state, app_state, buffer_state).await;
let message = register::back_to_main(register_state, app_state).await;
return Some(Ok(EventOutcome::Ok(message))); return Some(Ok(EventOutcome::Ok(message)));
} }
_ => { // Default for RegisterSuccess _ => { // Default for RegisterSuccess

View File

@@ -196,7 +196,7 @@ impl EventHandler {
UiContext::Register => { UiContext::Register => {
message = match index { message = match index {
0 => register::save(register_state, &mut self.auth_client, app_state).await?, 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(), _ => "Invalid Login Option".to_string(),
}; };
} }

View File

@@ -99,8 +99,8 @@ pub async fn back_to_main(
// Ensure dialog is hidden if revert is called // Ensure dialog is hidden if revert is called
app_state.hide_dialog(); // Uncomment if needed app_state.hide_dialog(); // Uncomment if needed
// Navigation logic (currently disabled in original code) // Navigation logic
let closed = buffer_state.close_active_buffer(); buffer_state.close_active_buffer();
buffer_state.update_history(AppView::Intro); buffer_state.update_history(AppView::Intro);
// Reset focus state // Reset focus state

View File

@@ -1,14 +1,13 @@
// src/tui/functions/common/register.rs // src/tui/functions/common/register.rs
use crate::{ use crate::services::auth::AuthClient;
services::auth::AuthClient, use crate::state::{
state::{ pages::auth::RegisterState,
pages::auth::RegisterState, app::state::AppState,
app::state::AppState, pages::canvas_state::CanvasState,
pages::canvas_state::CanvasState,
},
ui::handlers::context::DialogPurpose,
}; };
use crate::ui::handlers::context::DialogPurpose;
use crate::state::app::buffer::{AppView, BufferState};
/// Attempts to register the user using the provided details via gRPC. /// Attempts to register the user using the provided details via gRPC.
/// Updates RegisterState and AppState on success or failure. /// 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. /// 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, register_state: &mut RegisterState,
app_state: &mut AppState, app_state: &mut AppState,
buffer_state: &mut BufferState,
) -> String { ) -> String {
// Clear fields first // Clear fields first
let _ = revert(register_state, app_state).await; let _ = revert(register_state, app_state).await;
@@ -142,8 +142,8 @@ pub async fn back_to_main(
app_state.hide_dialog(); app_state.hide_dialog();
// Navigation logic // Navigation logic
app_state.ui.show_register = false; buffer_state.close_active_buffer();
app_state.ui.show_intro = true; buffer_state.update_history(AppView::Login);
// Reset focus state // Reset focus state
app_state.ui.focus_outside_canvas = false; app_state.ui.focus_outside_canvas = false;