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

@@ -8,6 +8,7 @@ use crate::modes::common::commands::CommandHandler;
use crate::config::binds::config::Config;
use crate::state::pages::form::FormState;
use crate::state::pages::auth::AuthState;
use crate::state::pages::auth::LoginState;
use crate::state::pages::auth::RegisterState;
use crate::state::canvas_state::CanvasState;
use crate::ui::handlers::rat_state::UiStateHandler;
@@ -65,6 +66,7 @@ impl EventHandler {
command_handler: &mut CommandHandler,
form_state: &mut FormState,
auth_state: &mut AuthState,
login_state: &mut LoginState,
register_state: &mut RegisterState,
app_state: &mut crate::state::state::AppState,
total_count: u64,
@@ -76,7 +78,7 @@ impl EventHandler {
// --- DIALOG MODALITY ---
if app_state.ui.dialog.dialog_show {
if let Some(dialog_result) = dialog::handle_dialog_event(
&event, config, app_state, auth_state, register_state, &mut self.auth_client
&event, config, app_state, auth_state, login_state, register_state
).await {
return dialog_result;
}
@@ -102,7 +104,8 @@ impl EventHandler {
config,
form_state,
app_state,
auth_state,
login_state,
register_state,
&mut self.command_mode,
&mut self.command_input,
&mut self.command_message,
@@ -117,8 +120,8 @@ impl EventHandler {
}
UiContext::Login => {
message = match index {
0 => login::save(auth_state, &mut self.auth_client, app_state).await?,
1 => login::back_to_main(auth_state, app_state).await,
0 => login::save(auth_state, login_state, &mut self.auth_client, app_state).await?,
1 => login::back_to_main(login_state, app_state).await,
_ => "Invalid Login Option".to_string(),
};
}
@@ -157,20 +160,20 @@ impl EventHandler {
if config.is_enter_edit_mode_after(key_code, modifiers) &&
ModeManager::can_enter_edit_mode(current_mode) {
let current_input = if app_state.ui.show_login || app_state.ui.show_register{
auth_state.get_current_input()
login_state.get_current_input()
} else {
form_state.get_current_input()
};
let current_cursor_pos = if app_state.ui.show_login || app_state.ui.show_register{
auth_state.current_cursor_pos()
login_state.current_cursor_pos()
} else {
form_state.current_cursor_pos()
};
if !current_input.is_empty() && current_cursor_pos < current_input.len() {
if app_state.ui.show_login || app_state.ui.show_register{
auth_state.set_current_cursor_pos(current_cursor_pos + 1);
self.ideal_cursor_column = auth_state.current_cursor_pos();
login_state.set_current_cursor_pos(current_cursor_pos + 1);
self.ideal_cursor_column = login_state.current_cursor_pos();
} else {
form_state.set_current_cursor_pos(current_cursor_pos + 1);
self.ideal_cursor_column = form_state.current_cursor_pos();
@@ -203,6 +206,7 @@ impl EventHandler {
action,
form_state,
auth_state,
login_state,
register_state,
grpc_client,
&mut self.auth_client,
@@ -221,7 +225,7 @@ impl EventHandler {
key,
config,
form_state,
auth_state,
login_state,
register_state,
&mut self.key_sequence_tracker,
current_position,
@@ -240,7 +244,7 @@ impl EventHandler {
self.edit_mode_cooldown = true;
let has_changes = if app_state.ui.show_login || app_state.ui.show_register{
auth_state.has_unsaved_changes()
login_state.has_unsaved_changes()
} else {
form_state.has_unsaved_changes()
};
@@ -254,12 +258,12 @@ impl EventHandler {
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
let current_input = if app_state.ui.show_login || app_state.ui.show_register{
auth_state.get_current_input()
login_state.get_current_input()
} else {
form_state.get_current_input()
};
let current_cursor_pos = if app_state.ui.show_login || app_state.ui.show_register{
auth_state.current_cursor_pos()
login_state.current_cursor_pos()
} else {
form_state.current_cursor_pos()
};
@@ -267,8 +271,8 @@ impl EventHandler {
if !current_input.is_empty() && current_cursor_pos >= current_input.len() {
let new_pos = current_input.len() - 1;
if app_state.ui.show_login || app_state.ui.show_register{
auth_state.set_current_cursor_pos(new_pos);
self.ideal_cursor_column = auth_state.current_cursor_pos();
login_state.set_current_cursor_pos(new_pos);
self.ideal_cursor_column = login_state.current_cursor_pos();
} else {
form_state.set_current_cursor_pos(new_pos);
self.ideal_cursor_column = form_state.current_cursor_pos();
@@ -288,6 +292,7 @@ impl EventHandler {
action,
form_state,
auth_state,
login_state,
register_state,
grpc_client,
&mut self.auth_client,
@@ -305,7 +310,7 @@ impl EventHandler {
key,
config,
form_state,
auth_state,
login_state,
register_state,
&mut self.ideal_cursor_column,
&mut self.command_message,
@@ -324,7 +329,8 @@ impl EventHandler {
key,
config,
app_state,
auth_state,
login_state,
register_state,
form_state,
&mut self.command_input,
&mut self.command_message,