2
0

fix(engine): 🐛 Current id bug when linking to current bot

This commit is contained in:
Baptiste Arnaud
2022-04-04 10:23:34 +02:00
parent 082270370b
commit da95cbd355

View File

@ -148,11 +148,12 @@ const executeTypebotLink = async (
}> => {
const { typebot, linkedTypebots, onNewLog, createEdge, setCurrentTypebotId } =
context
const linkedTypebot =
const linkedTypebot = (
step.options.typebotId === 'current'
? typebot
: [typebot, ...linkedTypebots].find(byId(step.options.typebotId)) ??
(await fetchAndInjectTypebot(step, context))
) as PublicTypebot | LinkedTypebot | undefined
if (!linkedTypebot) {
onNewLog({
status: 'error',
@ -161,7 +162,9 @@ const executeTypebotLink = async (
})
return { nextEdgeId: step.outgoingEdgeId }
}
setCurrentTypebotId(linkedTypebot.id)
setCurrentTypebotId(
'typebotId' in linkedTypebot ? linkedTypebot.typebotId : linkedTypebot.id
)
const nextBlockId =
step.options.blockId ??
linkedTypebot.blocks.find((b) => b.steps.some((s) => s.type === 'start'))