Skip to content

Commit

Permalink
added check that types match after new actions are loaded
Browse files Browse the repository at this point in the history
fixes #216
  • Loading branch information
lilopkins committed Dec 9, 2024
1 parent 0b43bbe commit ff4a8f0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion testangel/src/ui/flows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,40 @@ impl Component for FlowsModel {
let mut close_flow = false;
let mut steps_reset = vec![];
if let Some(flow) = &mut self.open_flow {
let actions_clone = flow.actions.clone();
for (step, ac) in flow.actions.iter_mut().enumerate() {
match self.action_map.get_action_by_id(&ac.action_id) {
None => {
close_flow = true;
}
Some(action) => {
// Check that action parameters haven't changed. If they have, reset values.
if ac.update(action) {
if ac.update(action.clone()) {
steps_reset.push(step);
}

// Check that the references from this AC to another don't now violate types
for (p_id, src) in &mut ac.parameter_sources {
match src {
ActionParameterSource::FromOutput(other_step, output) => {
let (_name, kind) = &action.parameters()[*p_id];
// Check that parameter from step->output is of type kind
if let Some(other_ac) = actions_clone.get(*other_step) {
if let Some(other_action) = &self.action_map.get_action_by_id(&other_ac.action_id) {
if let Some((_name, other_output_kind)) = other_action.outputs().get(*output) {
if kind != other_output_kind {
// Reset to literal
steps_reset.push(step);
*src = ActionParameterSource::Literal;
}
}
}
}
// If any of these if's fail, then the main loop will catch and fail later.
},
_ => (),
}
}
}
}
}
Expand Down

0 comments on commit ff4a8f0

Please sign in to comment.