Skip to content

Commit

Permalink
fix(engine): 🐛 Current id bug when linking to current bot
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Apr 4, 2022
1 parent 0822703 commit da95cbd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/bot-engine/src/services/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'))
Expand Down

0 comments on commit da95cbd

Please sign in to comment.