From 87344117cb948ac2359094656f99ef10ee345360 Mon Sep 17 00:00:00 2001 From: Adam Gough Date: Mon, 2 Jun 2025 13:07:11 -0700 Subject: [PATCH] added back sync logic --- apps/sim/stores/workflows/sync.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/sim/stores/workflows/sync.ts b/apps/sim/stores/workflows/sync.ts index e06ba5de5a..c2fbeb412b 100644 --- a/apps/sim/stores/workflows/sync.ts +++ b/apps/sim/stores/workflows/sync.ts @@ -285,6 +285,24 @@ export async function fetchWorkflowsFromDB(): Promise { }) }) + // Get any additional subblock values that might not be in the state but are in the store + const storedValues = useSubBlockStore.getState().workflowValues[id] || {} + Object.entries(storedValues).forEach(([blockId, blockValues]) => { + if (!subblockValues[blockId]) { + subblockValues[blockId] = {} + } + + Object.entries(blockValues).forEach(([subblockId, value]) => { + // Only update if not already set or if value is null + if ( + subblockValues[blockId][subblockId] === null || + subblockValues[blockId][subblockId] === undefined + ) { + subblockValues[blockId][subblockId] = value + } + }) + }) + // 4. Store the workflow state and subblock values in localStorage // This ensures compatibility with existing code that loads from localStorage localStorage.setItem(`workflow-${id}`, JSON.stringify(workflowState))