now for common in canvas
This commit is contained in:
@@ -125,7 +125,7 @@ impl EventHandler {
|
||||
) {
|
||||
match action {
|
||||
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
||||
return self.handle_core_action(
|
||||
return common::handle_core_action(
|
||||
action,
|
||||
form_state,
|
||||
grpc_client,
|
||||
@@ -184,7 +184,7 @@ impl EventHandler {
|
||||
) {
|
||||
match action {
|
||||
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
||||
return self.handle_core_action(
|
||||
return common::handle_core_action(
|
||||
action,
|
||||
form_state,
|
||||
grpc_client,
|
||||
@@ -243,48 +243,5 @@ impl EventHandler {
|
||||
Ok((false, self.command_message.clone()))
|
||||
}
|
||||
|
||||
// Helper method for handling core application actions (not navigation)
|
||||
async fn handle_core_action(
|
||||
&mut self,
|
||||
action: &str,
|
||||
form_state: &mut FormState,
|
||||
grpc_client: &mut GrpcClient,
|
||||
command_handler: &mut CommandHandler,
|
||||
terminal: &mut TerminalCore,
|
||||
app_state: &mut crate::state::state::AppState,
|
||||
current_position: &mut u64,
|
||||
total_count: u64,
|
||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||
match action {
|
||||
"save" => {
|
||||
let message = common::save(
|
||||
form_state,
|
||||
grpc_client,
|
||||
&mut app_state.ui.is_saved,
|
||||
current_position,
|
||||
total_count,
|
||||
).await?;
|
||||
Ok((false, message))
|
||||
},
|
||||
"force_quit" => {
|
||||
let (should_exit, message) = command_handler.handle_command("force_quit", terminal).await?;
|
||||
Ok((should_exit, message))
|
||||
},
|
||||
"save_and_quit" => {
|
||||
let (should_exit, message) = command_handler.handle_command("save_and_quit", terminal).await?;
|
||||
Ok((should_exit, message))
|
||||
},
|
||||
"revert" => {
|
||||
let message = common::revert(
|
||||
form_state,
|
||||
grpc_client,
|
||||
current_position,
|
||||
total_count,
|
||||
).await?;
|
||||
Ok((false, message))
|
||||
},
|
||||
// We should never hit this case given our filtering above
|
||||
_ => Ok((false, format!("Core action not handled: {}", action))),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user