Feat: cleanup

This commit is contained in:
2026-02-22 13:28:03 +01:00
parent 3093b40dbc
commit 3d552ec072
26 changed files with 213 additions and 181 deletions

View File

@@ -12,9 +12,12 @@ use crate::state::{
pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> InputResult {
match &mut ctx.app.ui.modal {
Modal::Confirm { action, selected } => {
let (action, confirmed) = (action.clone(), *selected);
let confirmed = *selected;
match key.code {
KeyCode::Char('y') | KeyCode::Char('Y') => return execute_confirm(ctx, &action),
KeyCode::Char('y') | KeyCode::Char('Y') => {
let action = action.clone();
return execute_confirm(ctx, &action);
}
KeyCode::Char('n') | KeyCode::Char('N') | KeyCode::Esc => {
ctx.dispatch(AppCommand::CloseModal);
}
@@ -25,6 +28,7 @@ pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> Input
}
KeyCode::Enter => {
if confirmed {
let action = action.clone();
return execute_confirm(ctx, &action);
}
ctx.dispatch(AppCommand::CloseModal);
@@ -35,17 +39,16 @@ pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> Input
Modal::FileBrowser(state) => match key.code {
KeyCode::Enter => {
use crate::state::file_browser::FileBrowserMode;
let mode = state.mode.clone();
let is_save = matches!(state.mode, FileBrowserMode::Save);
if let Some(path) = state.confirm() {
ctx.dispatch(AppCommand::CloseModal);
match mode {
FileBrowserMode::Save => ctx.dispatch(AppCommand::Save(path)),
FileBrowserMode::Load => {
let _ = ctx.seq_cmd_tx.send(SeqCommand::StopAll);
let _ = ctx.seq_cmd_tx.send(SeqCommand::ResetScriptState);
ctx.dispatch(AppCommand::Load(path));
super::load_project_samples(ctx);
}
if is_save {
ctx.dispatch(AppCommand::Save(path));
} else {
let _ = ctx.seq_cmd_tx.send(SeqCommand::StopAll);
let _ = ctx.seq_cmd_tx.send(SeqCommand::ResetScriptState);
ctx.dispatch(AppCommand::Load(path));
super::load_project_samples(ctx);
}
}
}
@@ -63,7 +66,6 @@ pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> Input
_ => {}
},
Modal::Rename { target, name } => {
let target = target.clone();
match key.code {
KeyCode::Enter => {
let new_name = if name.trim().is_empty() {
@@ -71,6 +73,7 @@ pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> Input
} else {
Some(name.clone())
};
let target = target.clone();
ctx.dispatch(rename_command(&target, new_name));
ctx.dispatch(AppCommand::CloseModal);
}