fixing warnings

This commit is contained in:
filipriec
2025-04-18 15:50:47 +02:00
parent 11e8f87fe6
commit 6010b9a0af
4 changed files with 64 additions and 141 deletions

View File

@@ -257,125 +257,58 @@ pub async fn handle_edit_event(
}
// --- Character insertion ---
if let KeyCode::Char(c) = key.code {
if app_state.ui.show_register && register_state.in_suggestion_mode {
register_state.in_suggestion_mode = false;
register_state.show_role_suggestions = false;
register_state.selected_suggestion_index = None;
}
let msg = if app_state.ui.show_login {
auth_e::execute_edit_action(
"insert_char",
key,
login_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
.await?
} else if app_state.ui.show_add_table {
add_table_e::execute_edit_action(
"insert_char",
key,
add_table_state,
ideal_cursor_column,
)
.await?
} else if app_state.ui.show_register {
auth_e::execute_edit_action(
"insert_char",
key,
register_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
.await?
} else {
form_e::execute_edit_action(
"insert_char",
key,
form_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
.await?
};
if app_state.ui.show_register && register_state.current_field() == 4 {
register_state.update_role_suggestions();
}
return Ok(EditEventOutcome::Message(msg));
if app_state.ui.show_register && register_state.in_suggestion_mode {
register_state.in_suggestion_mode = false;
register_state.show_role_suggestions = false;
register_state.selected_suggestion_index = None;
}
// --- Handle Backspace/Delete ---
if matches!(key.code, KeyCode::Backspace | KeyCode::Delete) {
if app_state.ui.show_register && register_state.in_suggestion_mode {
register_state.in_suggestion_mode = false;
register_state.show_role_suggestions = false;
register_state.selected_suggestion_index = None;
}
let action_str = if key.code == KeyCode::Backspace {
"delete_char_backward"
} else {
"delete_char_forward"
};
let result_msg: String = if app_state.ui.show_login {
auth_e::execute_edit_action(
action_str,
key,
login_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
let msg = if app_state.ui.show_login {
auth_e::execute_edit_action(
"insert_char",
key,
login_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
.await?
} else if app_state.ui.show_add_table {
add_table_e::execute_edit_action(
action_str,
key,
add_table_state,
ideal_cursor_column,
)
} else if app_state.ui.show_add_table {
add_table_e::execute_edit_action(
"insert_char",
key,
add_table_state,
ideal_cursor_column,
)
.await?
} else if app_state.ui.show_register {
auth_e::execute_edit_action(
action_str,
key,
register_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
} else if app_state.ui.show_register {
auth_e::execute_edit_action(
"insert_char",
key,
register_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
.await?
} else {
form_e::execute_edit_action(
action_str,
key,
form_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count
).await?
};
if app_state.ui.show_register && register_state.current_field() == 4 {
register_state.update_role_suggestions();
}
} else {
form_e::execute_edit_action(
"insert_char",
key,
form_state,
ideal_cursor_column,
grpc_client,
current_position,
total_count,
)
.await?
};
return Ok(EditEventOutcome::Message(result_msg));
if app_state.ui.show_register && register_state.current_field() == 4 {
register_state.update_role_suggestions();
}
Ok(EditEventOutcome::Message("".to_string()))
return Ok(EditEventOutcome::Message(msg));
}

View File

@@ -59,10 +59,6 @@ pub async fn handle_read_only_event(
"previous_entry",
"next_entry",
];
// Add context actions specific to register if needed, otherwise reuse login/form ones
const CONTEXT_ACTIONS_REGISTER: &[&str] = &[
// Add actions like "next_field", "prev_field" if handled differently than general read-only
];
if key.modifiers.is_empty() {
key_sequence_tracker.add_key(key.code);
@@ -150,7 +146,7 @@ pub async fn handle_read_only_event(
key_sequence_tracker,
command_message,
).await?
} else if app_state.ui.show_register /* && CONTEXT_ACTIONS_REGISTER.contains(&action) */ { // Handle register general actions
} else if app_state.ui.show_register {
auth_ro::execute_action(
action,
app_state,
@@ -209,7 +205,7 @@ pub async fn handle_read_only_event(
key_sequence_tracker,
command_message,
).await?
} else if app_state.ui.show_register /* && CONTEXT_ACTIONS_REGISTER.contains(&action) */ { // Handle register general actions
} else if app_state.ui.show_register {
auth_ro::execute_action(
action,
app_state,

View File

@@ -5,7 +5,6 @@ use crate::config::binds::config::Config;
use crate::ui::handlers::context::DialogPurpose;
use crate::state::app::state::AppState;
use crate::state::app::buffer::BufferState;
use crate::state::pages::auth::AuthState;
use crate::state::pages::auth::{LoginState, RegisterState};
use crate::state::pages::admin::AdminState;
use crate::modes::handlers::event::EventOutcome;
@@ -19,7 +18,6 @@ pub async fn handle_dialog_event(
event: &Event,
config: &Config,
app_state: &mut AppState,
auth_state: &mut AuthState,
login_state: &mut LoginState,
register_state: &mut RegisterState,
buffer_state: &mut BufferState,

View File

@@ -118,7 +118,6 @@ impl EventHandler {
&event,
config,
app_state,
auth_state,
login_state,
register_state,
buffer_state,
@@ -184,17 +183,15 @@ impl EventHandler {
}
// --- Add Table Page Navigation ---
if app_state.ui.show_add_table {
if let Some(action) = config.get_general_action(key.code, key.modifiers) {
if add_table_nav::handle_add_table_navigation(
key,
config,
app_state,
&mut admin_state.add_table_state,
&mut self.command_message,
if add_table_nav::handle_add_table_navigation(
key,
config,
app_state,
&mut admin_state.add_table_state,
&mut self.command_message,
) {
return Ok(EventOutcome::Ok(self.command_message.clone()));
}
) {
return Ok(EventOutcome::Ok(self.command_message.clone()));
}
}
@@ -213,8 +210,7 @@ impl EventHandler {
).await;
match nav_outcome {
Ok(EventOutcome::ButtonSelected { context, index }) => {
let mut message = String::from("Selected");
match context {
let message = match context {
UiContext::Intro => {
intro::handle_intro_selection(app_state, buffer_state, index);
if app_state.ui.show_admin {
@@ -222,7 +218,7 @@ impl EventHandler {
admin_state.profile_list_state.select(Some(0));
}
}
message = format!("Intro Option {} selected", index);
format!("Intro Option {} selected", index)
}
UiContext::Login => {
let login_action_message = match index {
@@ -239,23 +235,23 @@ impl EventHandler {
1 => login::back_to_main(login_state, app_state, buffer_state).await,
_ => "Invalid Login Option".to_string(),
};
message = login_action_message;
login_action_message
}
UiContext::Register => {
message = match index {
match index {
0 => register::save(register_state, &mut self.auth_client, app_state).await?,
1 => register::back_to_login(register_state, app_state, buffer_state).await,
_ => "Invalid Login Option".to_string(),
};
}
}
UiContext::Admin => {
admin::handle_admin_selection(app_state, admin_state);
message = format!("Admin Option {} selected", index);
format!("Admin Option {} selected", index)
}
UiContext::Dialog => {
message = "Internal error: Unexpected dialog state".to_string();
"Internal error: Unexpected dialog state".to_string()
}
}
}; // Semicolon added here
return Ok(EventOutcome::Ok(message));
}
other => return other,