fix(logic): ⚡️ Make linked bot edge id work
This commit is contained in:
@@ -52,6 +52,7 @@ export const ChatBlock = ({
|
||||
injectLinkedTypebot,
|
||||
linkedTypebots,
|
||||
setCurrentTypebotId,
|
||||
pushEdgeIdInLinkedTypebotQueue,
|
||||
} = useTypebot()
|
||||
const { resultValues, updateVariables } = useAnswers()
|
||||
const [processedSteps, setProcessedSteps] = useState<Step[]>([])
|
||||
@@ -113,6 +114,7 @@ export const ChatBlock = ({
|
||||
onNewLog,
|
||||
createEdge,
|
||||
setCurrentTypebotId,
|
||||
pushEdgeIdInLinkedTypebotQueue,
|
||||
})
|
||||
nextEdgeId ? onBlockEnd(nextEdgeId, linkedTypebot) : displayNextStep()
|
||||
}
|
||||
|
||||
@@ -21,7 +21,12 @@ export const ConversationContainer = ({
|
||||
onNewBlockVisible,
|
||||
onCompleted,
|
||||
}: Props) => {
|
||||
const { typebot, updateVariableValue } = useTypebot()
|
||||
const {
|
||||
typebot,
|
||||
updateVariableValue,
|
||||
linkedBotEdgeIdsQueue,
|
||||
popEdgeIdFromLinkedTypebotQueue,
|
||||
} = useTypebot()
|
||||
const { document: frameDocument } = useFrame()
|
||||
const [displayedBlocks, setDisplayedBlocks] = useState<
|
||||
{ block: Block; startStepIndex: number }[]
|
||||
@@ -36,7 +41,14 @@ export const ConversationContainer = ({
|
||||
) => {
|
||||
const currentTypebot = updatedTypebot ?? typebot
|
||||
const nextEdge = currentTypebot.edges.find(byId(edgeId))
|
||||
if (!nextEdge) return onCompleted()
|
||||
if (!nextEdge) {
|
||||
if (linkedBotEdgeIdsQueue.length > 0) {
|
||||
const nextEdgeId = linkedBotEdgeIdsQueue[0]
|
||||
popEdgeIdFromLinkedTypebotQueue()
|
||||
displayNextBlock(nextEdgeId)
|
||||
}
|
||||
return onCompleted()
|
||||
}
|
||||
const nextBlock = currentTypebot.blocks.find(byId(nextEdge.to.blockId))
|
||||
if (!nextBlock) return onCompleted()
|
||||
const startStepIndex = nextEdge.to.stepId
|
||||
|
||||
Reference in New Issue
Block a user