@@ -6,10 +6,9 @@ import {useSchemaAction} from "@edition/flow/components/FlowWorkerProvider";
66import { DatatypeService } from "@edition/datatype/services/Datatype.service" ;
77import { FunctionService } from "@edition/function/services/Function.service" ;
88import { NodeSchema } from "@code0-tech/triangulum" ;
9- import { FlowView } from "@edition/flow/services/Flow.view" ;
109
1110export const useFlowSchema = (
12- flow : Flow [ 'id' ] | FlowView ,
11+ flowId : Flow [ 'id' ] ,
1312 namespaceId : Namespace [ 'id' ] ,
1413 projectId : NamespaceProject [ 'id' ] ,
1514) : NodeSchema [ ] [ ] | undefined => {
@@ -23,9 +22,9 @@ export const useFlowSchema = (
2322
2423 const [ schema , setSchema ] = React . useState < NodeSchema [ ] [ ] | undefined > ( [ ] ) ;
2524
26- const flowView = React . useMemo (
27- ( ) => typeof flow === "string" ? flowService . getById ( flow , { namespaceId, projectId} ) : flow ,
28- [ flow , flowService , flowStore ]
25+ const flow = React . useMemo (
26+ ( ) => flowService . getById ( flowId , { namespaceId, projectId} ) ,
27+ [ flowId , flowService , flowStore ]
2928 )
3029
3130 const dataTypes = React . useMemo (
@@ -39,21 +38,21 @@ export const useFlowSchema = (
3938 )
4039
4140 React . useEffect ( ( ) => {
42- if ( ! flowView ) return
41+ if ( ! flow ) return
4342 if ( dataTypes . length <= 0 ) return
4443 if ( functions . length <= 0 ) return
4544
4645 let cancelled = false
4746
4847 const triggerSchema = execute ( {
49- flow : flowView ,
48+ flow,
5049 dataTypes,
5150 functions
5251 } )
5352
54- const schemas = flowView . nodes ?. nodes ?. map ( node => {
53+ const schemas = flow . nodes ?. nodes ?. map ( node => {
5554 return execute ( {
56- flow : flowView ,
55+ flow,
5756 dataTypes,
5857 functions,
5958 nodeId : node ?. id
@@ -68,7 +67,7 @@ export const useFlowSchema = (
6867 return ( ) => {
6968 cancelled = true
7069 }
71- } , [ functions . length , dataTypes . length , flowStore , flowView ?. editedAt , flowView ?. nodes ?. nodes ?. length ] )
70+ } , [ functions . length , dataTypes . length , flowStore , flow ?. editedAt , flow ?. nodes ?. nodes ?. length ] )
7271
7372 return schema
7473}
0 commit comments