we successfully compiled and wen from auth state to login state and auth state

This commit is contained in:
filipriec
2025-04-13 17:47:00 +02:00
parent 1dd5f685a6
commit 3d0a9f2082
14 changed files with 120 additions and 114 deletions

View File

@@ -5,6 +5,7 @@ use crate::config::binds::key_sequences::KeySequenceTracker;
use crate::services::grpc_client::GrpcClient;
use crate::state::{canvas_state::CanvasState, pages::auth::RegisterState};
use crate::state::pages::auth::AuthState;
use crate::state::pages::auth::LoginState;
use crate::state::pages::form::FormState;
use crate::state::state::AppState;
use crate::functions::modes::read_only::{auth_ro, form_ro};
@@ -15,7 +16,7 @@ pub async fn handle_read_only_event(
key: KeyEvent,
config: &Config,
form_state: &mut FormState,
auth_state: &mut AuthState,
login_state: &mut LoginState,
register_state: &mut RegisterState,
key_sequence_tracker: &mut KeySequenceTracker,
current_position: &mut u64,
@@ -34,8 +35,8 @@ pub async fn handle_read_only_event(
if config.is_enter_edit_mode_after(key.code, key.modifiers) {
let (current_input, current_pos) = if app_state.ui.show_login { // Check Login first
(
auth_state.get_current_input(),
auth_state.current_cursor_pos(),
login_state.get_current_input(),
login_state.current_cursor_pos(),
)
} else if app_state.ui.show_register { // Then check Register
(
@@ -51,8 +52,8 @@ pub async fn handle_read_only_event(
if !current_input.is_empty() && current_pos < current_input.len() {
if app_state.ui.show_login {
auth_state.set_current_cursor_pos(current_pos + 1);
*ideal_cursor_column = auth_state.current_cursor_pos();
login_state.set_current_cursor_pos(current_pos + 1);
*ideal_cursor_column = login_state.current_cursor_pos();
} else if app_state.ui.show_register {
register_state.set_current_cursor_pos(current_pos + 1);
*ideal_cursor_column = register_state.current_cursor_pos();
@@ -95,12 +96,7 @@ pub async fn handle_read_only_event(
)
.await?
} else if app_state.ui.show_login && CONTEXT_ACTIONS_LOGIN.contains(&action) { // Handle login context actions
crate::tui::functions::login::handle_action(
action,
auth_state,
ideal_cursor_column,
)
.await?
crate::tui::functions::login::handle_action(action).await?
} else if app_state.ui.show_register{
auth_ro::execute_action(
action,
@@ -114,7 +110,7 @@ pub async fn handle_read_only_event(
auth_ro::execute_action(
action,
app_state,
auth_state,
login_state,
ideal_cursor_column,
key_sequence_tracker,
command_message,
@@ -151,12 +147,7 @@ pub async fn handle_read_only_event(
)
.await?
} else if app_state.ui.show_login && CONTEXT_ACTIONS_LOGIN.contains(&action) { // Handle login context actions
crate::tui::functions::login::handle_action(
action,
auth_state,
ideal_cursor_column,
)
.await?
crate::tui::functions::login::handle_action(action).await?
} else if app_state.ui.show_register /* && CONTEXT_ACTIONS_REGISTER.contains(&action) */ { // Handle register general actions
auth_ro::execute_action(
action,
@@ -170,7 +161,7 @@ pub async fn handle_read_only_event(
auth_ro::execute_action(
action,
app_state,
auth_state,
login_state,
ideal_cursor_column,
key_sequence_tracker,
command_message,
@@ -206,12 +197,7 @@ pub async fn handle_read_only_event(
)
.await?
} else if app_state.ui.show_login && CONTEXT_ACTIONS_LOGIN.contains(&action) { // Handle login context actions
crate::tui::functions::login::handle_action(
action,
auth_state,
ideal_cursor_column,
)
.await?
crate::tui::functions::login::handle_action(action).await?
} else if app_state.ui.show_register /* && CONTEXT_ACTIONS_REGISTER.contains(&action) */ { // Handle register general actions
auth_ro::execute_action(
action,
@@ -225,7 +211,7 @@ pub async fn handle_read_only_event(
auth_ro::execute_action(
action,
app_state,
auth_state,
login_state,
ideal_cursor_column,
key_sequence_tracker,
command_message,