wwf
2 天以前 a430284aa21e3ae1f0d5654e55b2ad2852519cc2
app/components/workflow/hooks/use-nodes-data.ts
@@ -31,7 +31,7 @@
  }), [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)
@@ -42,36 +42,21 @@
  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])
}