fix(frontend): Reload the flowStateStore when a node is restored (undo) (#4049)

This commit is contained in:
Faton Ramadani
2024-07-09 13:29:17 +02:00
committed by GitHub
parent e775cf351f
commit 6e526327dd

View File

@@ -1075,7 +1075,25 @@
undoProps={{ disabled: $history.index === 0 }}
redoProps={{ disabled: $history.index === $history.history.length - 1 }}
on:undo={() => {
const currentModules = $flowStore?.value?.modules
$flowStore = undo(history, $flowStore)
const newModules = $flowStore?.value?.modules
const restoredModules = newModules?.filter(
(node) => !currentModules?.some((currentNode) => currentNode?.id === node?.id)
)
for (const mod of restoredModules) {
if (mod) {
try {
loadFlowModuleState(mod).then((state) => ($flowStateStore[mod.id] = state))
} catch (e) {
console.error('Error loading state for restored node', e)
}
}
}
$selectedIdStore = 'Input'
}}
on:redo={() => {