Skip to content

Commit 391925a

Browse files
Adam GoughAdam Gough
authored andcommitted
fix: removed sync logic that was causing undefined block error and added isloading
1 parent f93a1bf commit 391925a

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

apps/sim/app/w/[id]/components/control-bar/control-bar.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function ControlBar() {
9898
removeWorkflow,
9999
duplicateWorkflow,
100100
setDeploymentStatus,
101+
isLoading: isRegistryLoading,
101102
} = useWorkflowRegistry()
102103
const { isExecuting, handleRunWorkflow } = useWorkflowExecution()
103104
const { setActiveTab } = usePanelStore()
@@ -257,14 +258,20 @@ export function ControlBar() {
257258
return
258259
}
259260

261+
if (isRegistryLoading) {
262+
setDeployedState(null)
263+
setIsLoadingDeployedState(false)
264+
return
265+
}
266+
260267
if (isDeployed) {
261268
setNeedsRedeploymentFlag(false)
262269
fetchDeployedState()
263270
} else {
264271
setDeployedState(null)
265272
setIsLoadingDeployedState(false)
266273
}
267-
}, [activeWorkflowId, isDeployed, setNeedsRedeploymentFlag])
274+
}, [activeWorkflowId, isDeployed, setNeedsRedeploymentFlag, isRegistryLoading])
268275

269276
// Get current store state for change detection
270277
const currentBlocks = useWorkflowStore((state) => state.blocks)
@@ -321,15 +328,15 @@ export function ControlBar() {
321328
}, [activeWorkflowId, deployedState, currentBlocks, subBlockValues, isLoadingDeployedState])
322329

323330
useEffect(() => {
324-
if (session?.user?.id) {
331+
if (session?.user?.id && !isRegistryLoading) {
325332
checkUserUsage(session.user.id).then((usage) => {
326333
if (usage) {
327334
setUsageExceeded(usage.isExceeded)
328335
setUsageData(usage)
329336
}
330337
})
331338
}
332-
}, [session?.user?.id, completedRuns])
339+
}, [session?.user?.id, completedRuns, isRegistryLoading])
333340

334341
/**
335342
* Check user usage data with caching to prevent excessive API calls

apps/sim/stores/workflows/sync.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -285,24 +285,6 @@ export async function fetchWorkflowsFromDB(): Promise<void> {
285285
})
286286
})
287287

288-
// Get any additional subblock values that might not be in the state but are in the store
289-
const storedValues = useSubBlockStore.getState().workflowValues[id] || {}
290-
Object.entries(storedValues).forEach(([blockId, blockValues]) => {
291-
if (!subblockValues[blockId]) {
292-
subblockValues[blockId] = {}
293-
}
294-
295-
Object.entries(blockValues).forEach(([subblockId, value]) => {
296-
// Only update if not already set or if value is null
297-
if (
298-
subblockValues[blockId][subblockId] === null ||
299-
subblockValues[blockId][subblockId] === undefined
300-
) {
301-
subblockValues[blockId][subblockId] = value
302-
}
303-
})
304-
})
305-
306288
// 4. Store the workflow state and subblock values in localStorage
307289
// This ensures compatibility with existing code that loads from localStorage
308290
localStorage.setItem(`workflow-${id}`, JSON.stringify(workflowState))

0 commit comments

Comments
 (0)