Skip to content

Commit

Permalink
fix(switch): 🐛 Fixed saving of variables in case-by-case validation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
egalvis39 authored Mar 5, 2024
1 parent 4a23f1a commit c339ff9
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions menuflow/nodes/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def get_case_by_id(self, id: str | int) -> str:
case_result: Dict = cases[id]

# Load variables defined in the case into the room
await self.load_variables(case_result)
await self.load_variables(case_result.get("variables", {}))

case_o_connection = self.render_data(case_result.get("o_connection"))

Expand Down Expand Up @@ -193,7 +193,7 @@ async def validate_cases(self) -> str:

return case_o_connection

async def load_variables(self, case: Dict) -> None:
async def load_variables(self, variables: Dict) -> None:
"""This function loads variables defined in switch cases into the room.
Parameters
Expand All @@ -203,16 +203,18 @@ async def load_variables(self, case: Dict) -> None:
"""
variables_recorded = []
if case.get("variables") and self.room:
for variable in case.get("variables", {}):
if variable in variables_recorded:
continue

await self.room.set_variable(
variable_id=variable,
value=self.render_data(case["variables"][variable]),
)
variables_recorded.append(variable)
if not variables:
return

for variable in variables:
if variable in variables_recorded:
continue

await self.room.set_variable(
variable_id=variable,
value=self.render_data(variables[variable]),
)
variables_recorded.append(variable)

async def manage_case_exceptions(self) -> tuple[str, str]:
"""
Expand Down

0 comments on commit c339ff9

Please sign in to comment.