fix(engine): 🐛 Current id bug when linking to current bot
This commit is contained in:
@ -148,11 +148,12 @@ const executeTypebotLink = async (
|
|||||||
}> => {
|
}> => {
|
||||||
const { typebot, linkedTypebots, onNewLog, createEdge, setCurrentTypebotId } =
|
const { typebot, linkedTypebots, onNewLog, createEdge, setCurrentTypebotId } =
|
||||||
context
|
context
|
||||||
const linkedTypebot =
|
const linkedTypebot = (
|
||||||
step.options.typebotId === 'current'
|
step.options.typebotId === 'current'
|
||||||
? typebot
|
? typebot
|
||||||
: [typebot, ...linkedTypebots].find(byId(step.options.typebotId)) ??
|
: [typebot, ...linkedTypebots].find(byId(step.options.typebotId)) ??
|
||||||
(await fetchAndInjectTypebot(step, context))
|
(await fetchAndInjectTypebot(step, context))
|
||||||
|
) as PublicTypebot | LinkedTypebot | undefined
|
||||||
if (!linkedTypebot) {
|
if (!linkedTypebot) {
|
||||||
onNewLog({
|
onNewLog({
|
||||||
status: 'error',
|
status: 'error',
|
||||||
@ -161,7 +162,9 @@ const executeTypebotLink = async (
|
|||||||
})
|
})
|
||||||
return { nextEdgeId: step.outgoingEdgeId }
|
return { nextEdgeId: step.outgoingEdgeId }
|
||||||
}
|
}
|
||||||
setCurrentTypebotId(linkedTypebot.id)
|
setCurrentTypebotId(
|
||||||
|
'typebotId' in linkedTypebot ? linkedTypebot.typebotId : linkedTypebot.id
|
||||||
|
)
|
||||||
const nextBlockId =
|
const nextBlockId =
|
||||||
step.options.blockId ??
|
step.options.blockId ??
|
||||||
linkedTypebot.blocks.find((b) => b.steps.some((s) => s.type === 'start'))
|
linkedTypebot.blocks.find((b) => b.steps.some((s) => s.type === 'start'))
|
||||||
|
Reference in New Issue
Block a user