Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions apps/builder/contexts/TypebotContext/actions/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,27 @@ const deleteOutgoingEdgeIdProps = (
if (!edge) return

const fromBlockIndex = typebot.blocks.findIndex(byId(edge.from.blockId))
if (fromBlockIndex === -1) return

const fromStepIndex = typebot.blocks[fromBlockIndex].steps.findIndex(
byId(edge.from.stepId)
)
const fromBlock = typebot.blocks[fromBlockIndex]
if (!fromBlock?.steps) return

const fromStepIndex = fromBlock.steps.findIndex(byId(edge.from.stepId))

const step = typebot.blocks[fromBlockIndex].steps[fromStepIndex] as
| Step
| undefined
const step = fromBlock.steps[fromStepIndex] as Step | undefined

const fromItemIndex =
edge.from.itemId && step && stepHasItems(step)
? step.items.findIndex(byId(edge.from.itemId))
: -1

if (fromStepIndex !== -1)
typebot.blocks[fromBlockIndex].steps[fromStepIndex].outgoingEdgeId =
undefined
if (fromStepIndex !== -1 && fromBlock.steps[fromStepIndex])
fromBlock.steps[fromStepIndex].outgoingEdgeId = undefined

if (fromItemIndex !== -1)
(
typebot.blocks[fromBlockIndex].steps[fromStepIndex] as StepWithItems
).items[fromItemIndex].outgoingEdgeId = undefined
if (fromItemIndex !== -1 && step)
(fromBlock.steps[fromStepIndex] as StepWithItems).items[
fromItemIndex
].outgoingEdgeId = undefined
}

export const cleanUpEdgeDraft = (
Expand Down
Loading