@@ -43,9 +43,6 @@ function WorkflowContent() {
4343 // State
4444 const [ selectedEdgeId , setSelectedEdgeId ] = useState < string | null > ( null )
4545 const [ isInitialized , setIsInitialized ] = useState ( false )
46- const [ isPublicWorkflow , setIsPublicWorkflow ] = useState ( false )
47- const [ publicWorkflowData , setPublicWorkflowData ] = useState < any > ( null )
48- const [ loadingPublicWorkflow , setLoadingPublicWorkflow ] = useState ( false )
4946
5047 // Hooks
5148 const params = useParams ( )
@@ -54,16 +51,8 @@ function WorkflowContent() {
5451
5552 // Store access
5653 const { workflows, setActiveWorkflow, createWorkflow } = useWorkflowRegistry ( )
57- const {
58- blocks,
59- edges,
60- loops,
61- addBlock,
62- updateBlockPosition,
63- addEdge,
64- removeEdge,
65- initializeWorkflow,
66- } = useWorkflowStore ( )
54+ const { blocks, edges, loops, addBlock, updateBlockPosition, addEdge, removeEdge } =
55+ useWorkflowStore ( )
6756 const { setValue : setSubBlockValue } = useSubBlockStore ( )
6857 const { markAllAsRead } = useNotificationStore ( )
6958 const { resetLoaded : resetVariablesLoaded } = useVariablesStore ( )
@@ -162,47 +151,9 @@ function WorkflowContent() {
162151 return
163152 }
164153
165- // Check if the workflow is in the user's registry
166154 if ( ! workflows [ currentId ] ) {
167- // If not in registry, try to load it as a public workflow
168- setLoadingPublicWorkflow ( true )
169- try {
170- const response = await fetch ( `/api/workflows/public/${ currentId } ` )
171-
172- if ( response . ok ) {
173- // Workflow exists and is public
174- const data = await response . json ( )
175- setPublicWorkflowData ( data . data )
176- setIsPublicWorkflow ( true )
177-
178- // Initialize the workflow store with the public workflow state
179- if ( data . data ?. state ) {
180- const { blocks, edges, loops } = data . data . state
181- initializeWorkflow ( blocks || { } , edges || [ ] , loops || { } )
182-
183- // Initialize subblock store with workflow values
184- if ( blocks ) {
185- useSubBlockStore . getState ( ) . initializeFromWorkflow ( currentId , blocks )
186- }
187- }
188- setLoadingPublicWorkflow ( false )
189- return
190- } else if ( response . status === 403 ) {
191- // Workflow exists but is not public, redirect to first workflow
192- router . replace ( `/w/${ workflowIds [ 0 ] } ` )
193- return
194- } else {
195- // Workflow doesn't exist, redirect to first workflow
196- router . replace ( `/w/${ workflowIds [ 0 ] } ` )
197- return
198- }
199- } catch ( error ) {
200- console . error ( 'Error loading public workflow:' , error )
201- router . replace ( `/w/${ workflowIds [ 0 ] } ` )
202- return
203- } finally {
204- setLoadingPublicWorkflow ( false )
205- }
155+ router . replace ( `/w/${ workflowIds [ 0 ] } ` )
156+ return
206157 }
207158
208159 // Import the isActivelyLoadingFromDB function to check sync status
@@ -239,7 +190,6 @@ function WorkflowContent() {
239190 isInitialized ,
240191 markAllAsRead ,
241192 resetVariablesLoaded ,
242- initializeWorkflow ,
243193 ] )
244194
245195 // Transform blocks and loops into ReactFlow nodes
0 commit comments