| | |
| | | }), [t, isChatMode]) |
| | | } |
| | | |
| | | export const useAvailableBlocks = (nodeType?: BlockEnum, isInIteration?: boolean, isInLoop?: boolean) => { |
| | | export const useAvailableBlocks = (nodeType?: BlockEnum, isInIteration?: boolean) => { |
| | | const nodesExtraData = useNodesExtraData() |
| | | const availablePrevBlocks = useMemo(() => { |
| | | if (!nodeType) |
| | |
| | | const availableNextBlocks = useMemo(() => { |
| | | if (!nodeType) |
| | | return [] |
| | | |
| | | return nodesExtraData[nodeType].availableNextNodes || [] |
| | | }, [nodeType, nodesExtraData]) |
| | | |
| | | return useMemo(() => { |
| | | return { |
| | | availablePrevBlocks: availablePrevBlocks.filter((nType) => { |
| | | if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) |
| | | if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.End)) |
| | | return false |
| | | |
| | | if (isInLoop && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) |
| | | return false |
| | | |
| | | if (!isInLoop && nType === BlockEnum.LoopEnd) |
| | | return false |
| | | |
| | | return true |
| | | }), |
| | | availableNextBlocks: availableNextBlocks.filter((nType) => { |
| | | if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) |
| | | if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.End)) |
| | | return false |
| | | |
| | | if (isInLoop && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) |
| | | return false |
| | | |
| | | if (!isInLoop && nType === BlockEnum.LoopEnd) |
| | | return false |
| | | |
| | | return true |
| | | }), |
| | | } |
| | | }, [isInIteration, availablePrevBlocks, availableNextBlocks, isInLoop]) |
| | | }, [isInIteration, availablePrevBlocks, availableNextBlocks]) |
| | | } |