2
0

🐛 (transcript) Fix shift answers is not immutable

This commit is contained in:
Baptiste Arnaud
2024-08-13 16:01:22 +02:00
parent d49e006df0
commit 9218ef801d
4 changed files with 23 additions and 10 deletions

View File

@@ -27,16 +27,19 @@ import { stringifyError } from '@typebot.io/lib/stringifyError'
export const executeSetVariable = async (
state: SessionState,
block: SetVariableBlock
block: SetVariableBlock,
setVariableHistory: SetVariableHistoryItem[]
): Promise<ExecuteLogicResponse> => {
const { variables } = state.typebotsQueue[0].typebot
if (!block.options?.variableId)
return {
outgoingEdgeId: block.outgoingEdgeId,
}
const expressionToEvaluate = await getExpressionToEvaluate(state)(
block.options,
block.id
block.id,
setVariableHistory
)
const isCustomValue = !block.options.type || block.options.type === 'Custom'
const isCode =
@@ -139,7 +142,8 @@ const getExpressionToEvaluate =
(state: SessionState) =>
async (
options: SetVariableBlock['options'],
blockId: string
blockId: string,
setVariableHistory: SetVariableHistoryItem[]
): Promise<string | null> => {
switch (options?.type) {
case 'Contact name':
@@ -227,6 +231,8 @@ const getExpressionToEvaluate =
typebot: typebotWithEmptyVariables,
stopAtBlockId: blockId,
...props,
setVariableHistory:
props.setVariableHistory.concat(setVariableHistory),
})
return (
'return `' +