2
0

🐛 (typebotLink) Fix n+1 variable fill

Closes #1375
This commit is contained in:
Baptiste Arnaud
2024-03-26 19:25:03 +01:00
parent d0be29e257
commit c552fa7cc3

View File

@ -153,7 +153,7 @@ const addLinkedTypebotToState = async (
...linkedTypebot,
variables: fillVariablesWithExistingValues(
linkedTypebot.variables,
currentTypebotInQueue.typebot.variables
state.typebotsQueue
),
},
resultId: isPreview
@ -204,13 +204,16 @@ const createResumeEdgeIfNecessary = (
const fillVariablesWithExistingValues = (
emptyVariables: Variable[],
existingVariables: Variable[]
typebotsQueue: SessionState['typebotsQueue']
): Variable[] =>
emptyVariables.map((emptyVariable) => {
const matchedVariable = existingVariables.find(
(existingVariable) => existingVariable.name === emptyVariable.name
)
let matchedVariable
for (const typebotInQueue of typebotsQueue) {
matchedVariable = typebotInQueue.typebot.variables.find(
(v) => v.name === emptyVariable.name
)
if (matchedVariable) break
}
return {
...emptyVariable,
value: matchedVariable?.value,