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,7 +257,6 @@ pub async fn handle_edit_event(
} }
// --- Character insertion --- // --- Character insertion ---
if let KeyCode::Char(c) = key.code {
if app_state.ui.show_register && register_state.in_suggestion_mode { if app_state.ui.show_register && register_state.in_suggestion_mode {
register_state.in_suggestion_mode = false; register_state.in_suggestion_mode = false;
register_state.show_role_suggestions = false; register_state.show_role_suggestions = false;
@@ -312,70 +311,4 @@ pub async fn handle_edit_event(
} }
return Ok(EditEventOutcome::Message(msg)); return Ok(EditEventOutcome::Message(msg));
}
// --- 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,
)
.await?
} else if app_state.ui.show_add_table {
add_table_e::execute_edit_action(
action_str,
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,
)
.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();
}
return Ok(EditEventOutcome::Message(result_msg));
}
Ok(EditEventOutcome::Message("".to_string()))
} }

View File

@@ -59,10 +59,6 @@ pub async fn handle_read_only_event(
"previous_entry", "previous_entry",
"next_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() { if key.modifiers.is_empty() {
key_sequence_tracker.add_key(key.code); key_sequence_tracker.add_key(key.code);
@@ -150,7 +146,7 @@ pub async fn handle_read_only_event(
key_sequence_tracker, key_sequence_tracker,
command_message, command_message,
).await? ).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( auth_ro::execute_action(
action, action,
app_state, app_state,
@@ -209,7 +205,7 @@ pub async fn handle_read_only_event(
key_sequence_tracker, key_sequence_tracker,
command_message, command_message,
).await? ).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( auth_ro::execute_action(
action, action,
app_state, app_state,

View File

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

View File

@@ -118,7 +118,6 @@ impl EventHandler {
&event, &event,
config, config,
app_state, app_state,
auth_state,
login_state, login_state,
register_state, register_state,
buffer_state, buffer_state,
@@ -184,7 +183,6 @@ impl EventHandler {
} }
// --- Add Table Page Navigation --- // --- Add Table Page Navigation ---
if app_state.ui.show_add_table { 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( if add_table_nav::handle_add_table_navigation(
key, key,
config, config,
@@ -196,7 +194,6 @@ impl EventHandler {
return Ok(EventOutcome::Ok(self.command_message.clone())); return Ok(EventOutcome::Ok(self.command_message.clone()));
} }
} }
}
let nav_outcome = navigation::handle_navigation_event( let nav_outcome = navigation::handle_navigation_event(
key, key,
@@ -213,8 +210,7 @@ impl EventHandler {
).await; ).await;
match nav_outcome { match nav_outcome {
Ok(EventOutcome::ButtonSelected { context, index }) => { Ok(EventOutcome::ButtonSelected { context, index }) => {
let mut message = String::from("Selected"); let message = match context {
match context {
UiContext::Intro => { UiContext::Intro => {
intro::handle_intro_selection(app_state, buffer_state, index); intro::handle_intro_selection(app_state, buffer_state, index);
if app_state.ui.show_admin { if app_state.ui.show_admin {
@@ -222,7 +218,7 @@ impl EventHandler {
admin_state.profile_list_state.select(Some(0)); admin_state.profile_list_state.select(Some(0));
} }
} }
message = format!("Intro Option {} selected", index); format!("Intro Option {} selected", index)
} }
UiContext::Login => { UiContext::Login => {
let login_action_message = match index { let login_action_message = match index {
@@ -239,23 +235,23 @@ impl EventHandler {
1 => login::back_to_main(login_state, app_state, buffer_state).await, 1 => login::back_to_main(login_state, app_state, buffer_state).await,
_ => "Invalid Login Option".to_string(), _ => "Invalid Login Option".to_string(),
}; };
message = login_action_message; login_action_message
} }
UiContext::Register => { UiContext::Register => {
message = match index { 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_login(register_state, app_state, buffer_state).await, 1 => register::back_to_login(register_state, app_state, buffer_state).await,
_ => "Invalid Login Option".to_string(), _ => "Invalid Login Option".to_string(),
}; }
} }
UiContext::Admin => { UiContext::Admin => {
admin::handle_admin_selection(app_state, admin_state); admin::handle_admin_selection(app_state, admin_state);
message = format!("Admin Option {} selected", index); format!("Admin Option {} selected", index)
} }
UiContext::Dialog => { 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)); return Ok(EventOutcome::Ok(message));
} }
other => return other, other => return other,