we successfully compiled and wen from auth state to login state and auth state
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// src/modes/canvas/common_mode.rs
|
||||
|
||||
use crate::tui::terminal::core::TerminalCore;
|
||||
use crate::state::pages::{form::FormState, auth::AuthState, auth::RegisterState};
|
||||
use crate::state::pages::{form::FormState, auth::LoginState, auth::RegisterState, auth::AuthState};
|
||||
use crate::state::state::AppState;
|
||||
use crate::services::grpc_client::GrpcClient;
|
||||
use crate::services::auth::AuthClient;
|
||||
@@ -17,6 +17,7 @@ pub async fn handle_core_action(
|
||||
action: &str,
|
||||
form_state: &mut FormState,
|
||||
auth_state: &mut AuthState,
|
||||
login_state: &mut LoginState,
|
||||
register_state: &mut RegisterState,
|
||||
grpc_client: &mut GrpcClient,
|
||||
auth_client: &mut AuthClient,
|
||||
@@ -28,7 +29,7 @@ pub async fn handle_core_action(
|
||||
match action {
|
||||
"save" => {
|
||||
if app_state.ui.show_login {
|
||||
let message = login_save(auth_state, auth_client, app_state).await?;
|
||||
let message = login_save(auth_state, login_state, auth_client, app_state).await?;
|
||||
Ok(EventOutcome::Ok(message))
|
||||
} else if app_state.ui.show_register {
|
||||
let message = register_save(register_state, auth_client, app_state).await?;
|
||||
@@ -54,7 +55,7 @@ pub async fn handle_core_action(
|
||||
},
|
||||
"save_and_quit" => {
|
||||
let message = if app_state.ui.show_login {
|
||||
login_save(auth_state, auth_client, app_state).await?
|
||||
login_save(auth_state, login_state, auth_client, app_state).await?
|
||||
} else if app_state.ui.show_register {
|
||||
register_save(register_state, auth_client, app_state).await?
|
||||
} else {
|
||||
@@ -75,7 +76,7 @@ pub async fn handle_core_action(
|
||||
},
|
||||
"revert" => {
|
||||
if app_state.ui.show_login {
|
||||
let message = login_revert(auth_state, app_state).await;
|
||||
let message = login_revert(login_state, app_state).await;
|
||||
Ok(EventOutcome::Ok(message))
|
||||
} else if app_state.ui.show_register {
|
||||
let message = register_revert(register_state, app_state).await;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::config::binds::config::Config;
|
||||
use crate::services::grpc_client::GrpcClient;
|
||||
use crate::state::pages::{auth::{AuthState, RegisterState}};
|
||||
use crate::state::pages::{auth::{LoginState, RegisterState}};
|
||||
use crate::state::canvas_state::CanvasState;
|
||||
use crate::state::pages::form::FormState;
|
||||
use crate::functions::modes::edit::{auth_e, form_e};
|
||||
@@ -14,7 +14,7 @@ pub async fn handle_edit_event(
|
||||
key: KeyEvent,
|
||||
config: &Config,
|
||||
form_state: &mut FormState,
|
||||
auth_state: &mut AuthState,
|
||||
login_state: &mut LoginState,
|
||||
register_state: &mut RegisterState,
|
||||
ideal_cursor_column: &mut usize,
|
||||
command_message: &mut String,
|
||||
@@ -44,7 +44,7 @@ pub async fn handle_edit_event(
|
||||
let message = if app_state.ui.show_login {
|
||||
auth_e::execute_common_action(
|
||||
action,
|
||||
auth_state, // Concrete AuthState
|
||||
login_state,
|
||||
grpc_client,
|
||||
current_position,
|
||||
total_count
|
||||
@@ -99,7 +99,7 @@ pub async fn handle_edit_event(
|
||||
auth_e::execute_edit_action(
|
||||
action,
|
||||
key,
|
||||
auth_state,
|
||||
login_state,
|
||||
ideal_cursor_column,
|
||||
grpc_client,
|
||||
current_position,
|
||||
@@ -143,7 +143,7 @@ pub async fn handle_edit_event(
|
||||
auth_e::execute_edit_action(
|
||||
"insert_char",
|
||||
key,
|
||||
auth_state,
|
||||
login_state,
|
||||
ideal_cursor_column,
|
||||
grpc_client,
|
||||
current_position,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user