fix(engine): 🐛 Variable value reset
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user