Added state persistence before unload

This commit is contained in:
Emir Karabeg
2025-01-29 13:56:16 -08:00
parent 47dc2e78dc
commit 0984a60ca2

View File

@@ -195,6 +195,20 @@ const initializeRegistry = () => {
const workflows = JSON.parse(savedRegistry)
useWorkflowRegistry.setState({ workflows })
}
// Add event listeners for page unload
window.addEventListener('beforeunload', () => {
// Save current workflow state
const currentId = useWorkflowRegistry.getState().activeWorkflowId
if (currentId) {
const currentState = useWorkflowStore.getState()
localStorage.setItem(`workflow-${currentId}`, JSON.stringify({
blocks: currentState.blocks,
edges: currentState.edges,
history: currentState.history
}))
}
})
}
// Call this in your app's entry point