This commit is contained in:
filipriec
2025-04-10 16:05:06 +02:00
parent 6b241304fb
commit e729ed9df3
2 changed files with 50 additions and 15 deletions

View File

@@ -12,7 +12,7 @@ use crate::state::canvas_state::CanvasState;
use crate::ui::handlers::rat_state::UiStateHandler;
use crate::ui::handlers::context::UiContext;
use crate::tui::functions::{intro, admin};
use crate::tui::functions::common::login;
use crate::tui::functions::common::login;
use crate::modes::{
common::command_mode,
canvas::{edit, read_only, common_mode},
@@ -21,7 +21,6 @@ use crate::modes::{
use crate::config::binds::key_sequences::KeySequenceTracker;
use crate::modes::handlers::mode_manager::{ModeManager, AppMode};
use crate::tui::functions::common::form::SaveOutcome;
use crate::ui::handlers::context::DialogPurpose;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EventOutcome {
@@ -29,7 +28,6 @@ pub enum EventOutcome {
Exit(String),
DataSaved(SaveOutcome, String),
ButtonSelected { context: UiContext, index: usize },
DialogAction { purpose: DialogPurpose, selected_index: usize },
}
pub struct EventHandler {
@@ -76,14 +74,18 @@ impl EventHandler {
// --- DIALOG MODALITY ---
// If a dialog is showing, intercept and handle ONLY dialog inputs.
if app_state.ui.dialog.dialog_show {
if let Some(dialog_result) = dialog::handle_dialog_event(&event, config, app_state).await {
// Pass event handling to the dedicated dialog handler, including necessary state
if let Some(dialog_result) = dialog::handle_dialog_event(
&event, config, app_state, auth_state, &mut self.auth_client
).await {
// If the dialog handler consumed the event, return its result
return dialog_result;
}
}
// Fallback if dialog handler returned None or event wasn't handled
return Ok(EventOutcome::Ok(String::new()));
}
// --- END DIALOG MODALITY CHECK ---
if let Event::Key(key) = event {
let key_code = key.code;
let modifiers = key.modifiers;
@@ -128,9 +130,7 @@ impl EventHandler {
message = format!("Admin Option {} selected", index);
}
UiContext::Dialog => {
// Add specific dialog handling logic here
message = format!("Dialog Button {} selected", index);
app_state.hide_dialog(); // Example action
message = "Internal error: Unexpected dialog state".to_string();
}
}
return Ok(EventOutcome::Ok(message)); // Return Ok with message
@@ -325,7 +325,7 @@ impl EventHandler {
current_position,
total_count,
).await?;
if let EventOutcome::Ok(msg) = &outcome {
if msg == "Exited command mode" {
self.command_mode = false;