2
0

fix(engine): 🐛 Variable value reset

This commit is contained in:
Baptiste Arnaud
2022-05-31 08:17:04 +02:00
parent 5e19f796cc
commit a9f730b701

View File

@@ -66,11 +66,10 @@ const executeSetVariable = (
step: SetVariableStep, step: SetVariableStep,
{ typebot: { variables }, updateVariableValue, updateVariables }: LogicContext { typebot: { variables }, updateVariableValue, updateVariables }: LogicContext
): EdgeId | undefined => { ): EdgeId | undefined => {
if (!step.options?.variableId || !step.options.expressionToEvaluate) if (!step.options?.variableId) return step.outgoingEdgeId
return step.outgoingEdgeId const evaluatedExpression = step.options.expressionToEvaluate
const evaluatedExpression = evaluateExpression(variables)( ? evaluateExpression(variables)(step.options.expressionToEvaluate)
step.options.expressionToEvaluate : undefined
)
const existingVariable = variables.find(byId(step.options.variableId)) const existingVariable = variables.find(byId(step.options.variableId))
if (!existingVariable) return step.outgoingEdgeId if (!existingVariable) return step.outgoingEdgeId
updateVariableValue(existingVariable.id, evaluatedExpression) updateVariableValue(existingVariable.id, evaluatedExpression)