mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 23:17:59 -05:00
more
This commit is contained in:
@@ -2396,11 +2396,14 @@ const WorkflowContent = React.memo(() => {
|
||||
const selectedNodes = allNodes.filter((n) => n.selected)
|
||||
multiNodeDragStartRef.current.clear()
|
||||
selectedNodes.forEach((n) => {
|
||||
multiNodeDragStartRef.current.set(n.id, {
|
||||
x: n.position.x,
|
||||
y: n.position.y,
|
||||
parentId: blocks[n.id]?.data?.parentId,
|
||||
})
|
||||
const block = blocks[n.id]
|
||||
if (block) {
|
||||
multiNodeDragStartRef.current.set(n.id, {
|
||||
x: n.position.x,
|
||||
y: n.position.y,
|
||||
parentId: block.data?.parentId,
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
[blocks, setDragStartPosition, getNodes]
|
||||
|
||||
@@ -682,11 +682,10 @@ export function useUndoRedo() {
|
||||
userId,
|
||||
})
|
||||
|
||||
// Use setBlockEnabled to directly restore to previous state
|
||||
// This is more robust than conditional toggle in collaborative scenarios
|
||||
validBlockIds.forEach((blockId) => {
|
||||
const targetState = previousStates[blockId]
|
||||
if (workflowStore.blocks[blockId].enabled !== targetState) {
|
||||
workflowStore.toggleBlockEnabled(blockId)
|
||||
}
|
||||
workflowStore.setBlockEnabled(blockId, previousStates[blockId])
|
||||
})
|
||||
break
|
||||
}
|
||||
@@ -711,11 +710,10 @@ export function useUndoRedo() {
|
||||
userId,
|
||||
})
|
||||
|
||||
// Use setBlockHandles to directly restore to previous state
|
||||
// This is more robust than conditional toggle in collaborative scenarios
|
||||
validBlockIds.forEach((blockId) => {
|
||||
const targetState = previousStates[blockId]
|
||||
if (workflowStore.blocks[blockId].horizontalHandles !== targetState) {
|
||||
workflowStore.toggleBlockHandles(blockId)
|
||||
}
|
||||
workflowStore.setBlockHandles(blockId, previousStates[blockId])
|
||||
})
|
||||
break
|
||||
}
|
||||
@@ -1192,11 +1190,10 @@ export function useUndoRedo() {
|
||||
userId,
|
||||
})
|
||||
|
||||
// Use setBlockEnabled to directly set to toggled state
|
||||
// Redo sets to !previousStates (the state after the original toggle)
|
||||
validBlockIds.forEach((blockId) => {
|
||||
const targetState = !previousStates[blockId]
|
||||
if (workflowStore.blocks[blockId].enabled !== targetState) {
|
||||
workflowStore.toggleBlockEnabled(blockId)
|
||||
}
|
||||
workflowStore.setBlockEnabled(blockId, !previousStates[blockId])
|
||||
})
|
||||
break
|
||||
}
|
||||
@@ -1221,11 +1218,10 @@ export function useUndoRedo() {
|
||||
userId,
|
||||
})
|
||||
|
||||
// Use setBlockHandles to directly set to toggled state
|
||||
// Redo sets to !previousStates (the state after the original toggle)
|
||||
validBlockIds.forEach((blockId) => {
|
||||
const targetState = !previousStates[blockId]
|
||||
if (workflowStore.blocks[blockId].horizontalHandles !== targetState) {
|
||||
workflowStore.toggleBlockHandles(blockId)
|
||||
}
|
||||
workflowStore.setBlockHandles(blockId, !previousStates[blockId])
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
@@ -586,6 +586,27 @@ export const useWorkflowStore = create<WorkflowStore>()(
|
||||
// Note: Socket.IO handles real-time sync automatically
|
||||
},
|
||||
|
||||
setBlockEnabled: (id: string, enabled: boolean) => {
|
||||
const block = get().blocks[id]
|
||||
if (!block || block.enabled === enabled) return
|
||||
|
||||
const newState = {
|
||||
blocks: {
|
||||
...get().blocks,
|
||||
[id]: {
|
||||
...block,
|
||||
enabled,
|
||||
},
|
||||
},
|
||||
edges: [...get().edges],
|
||||
loops: { ...get().loops },
|
||||
parallels: { ...get().parallels },
|
||||
}
|
||||
|
||||
set(newState)
|
||||
get().updateLastSaved()
|
||||
},
|
||||
|
||||
duplicateBlock: (id: string) => {
|
||||
const block = get().blocks[id]
|
||||
if (!block) return
|
||||
@@ -668,6 +689,26 @@ export const useWorkflowStore = create<WorkflowStore>()(
|
||||
// Note: Socket.IO handles real-time sync automatically
|
||||
},
|
||||
|
||||
setBlockHandles: (id: string, horizontalHandles: boolean) => {
|
||||
const block = get().blocks[id]
|
||||
if (!block || block.horizontalHandles === horizontalHandles) return
|
||||
|
||||
const newState = {
|
||||
blocks: {
|
||||
...get().blocks,
|
||||
[id]: {
|
||||
...block,
|
||||
horizontalHandles,
|
||||
},
|
||||
},
|
||||
edges: [...get().edges],
|
||||
loops: { ...get().loops },
|
||||
}
|
||||
|
||||
set(newState)
|
||||
get().updateLastSaved()
|
||||
},
|
||||
|
||||
updateBlockName: (id: string, name: string) => {
|
||||
const oldBlock = get().blocks[id]
|
||||
if (!oldBlock) return { success: false, changedSubblocks: [] }
|
||||
|
||||
@@ -195,8 +195,10 @@ export interface WorkflowActions {
|
||||
clear: () => Partial<WorkflowState>
|
||||
updateLastSaved: () => void
|
||||
toggleBlockEnabled: (id: string) => void
|
||||
setBlockEnabled: (id: string, enabled: boolean) => void
|
||||
duplicateBlock: (id: string) => void
|
||||
toggleBlockHandles: (id: string) => void
|
||||
setBlockHandles: (id: string, horizontalHandles: boolean) => void
|
||||
updateBlockName: (
|
||||
id: string,
|
||||
name: string
|
||||
|
||||
Reference in New Issue
Block a user