mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 23:17:59 -05:00
remove unused code
This commit is contained in:
@@ -163,148 +163,3 @@ export function createInverseOperation(operation: Operation): Operation {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function operationToCollaborativePayload(operation: Operation): {
|
||||
operation: string
|
||||
target: string
|
||||
payload: Record<string, unknown>
|
||||
} {
|
||||
switch (operation.type) {
|
||||
case 'batch-add-blocks': {
|
||||
const op = operation as BatchAddBlocksOperation
|
||||
return {
|
||||
operation: 'batch-add-blocks',
|
||||
target: 'blocks',
|
||||
payload: {
|
||||
blocks: op.data.blockSnapshots,
|
||||
edges: op.data.edgeSnapshots,
|
||||
loops: {},
|
||||
parallels: {},
|
||||
subBlockValues: op.data.subBlockValues,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
case 'batch-remove-blocks': {
|
||||
const op = operation as BatchRemoveBlocksOperation
|
||||
return {
|
||||
operation: 'batch-remove-blocks',
|
||||
target: 'blocks',
|
||||
payload: { ids: op.data.blockSnapshots.map((b) => b.id) },
|
||||
}
|
||||
}
|
||||
|
||||
case 'add-edge':
|
||||
return {
|
||||
operation: 'add',
|
||||
target: 'edge',
|
||||
payload: { id: operation.data.edgeId },
|
||||
}
|
||||
|
||||
case 'batch-add-edges': {
|
||||
const op = operation as BatchAddEdgesOperation
|
||||
return {
|
||||
operation: 'batch-add-edges',
|
||||
target: 'edges',
|
||||
payload: {
|
||||
edges: op.data.edgeSnapshots.map((e) => ({
|
||||
id: e.id,
|
||||
source: e.source,
|
||||
target: e.target,
|
||||
sourceHandle: e.sourceHandle ?? null,
|
||||
targetHandle: e.targetHandle ?? null,
|
||||
})),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
case 'batch-remove-edges': {
|
||||
const op = operation as BatchRemoveEdgesOperation
|
||||
return {
|
||||
operation: 'batch-remove-edges',
|
||||
target: 'edges',
|
||||
payload: { ids: op.data.edgeSnapshots.map((e) => e.id) },
|
||||
}
|
||||
}
|
||||
|
||||
case 'batch-move-blocks': {
|
||||
const op = operation as BatchMoveBlocksOperation
|
||||
return {
|
||||
operation: 'batch-update-positions',
|
||||
target: 'blocks',
|
||||
payload: {
|
||||
moves: op.data.moves.map((m) => ({
|
||||
id: m.blockId,
|
||||
x: m.after.x,
|
||||
y: m.after.y,
|
||||
parentId: m.after.parentId,
|
||||
})),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
case 'update-parent':
|
||||
return {
|
||||
operation: 'update-parent',
|
||||
target: 'block',
|
||||
payload: {
|
||||
id: operation.data.blockId,
|
||||
parentId: operation.data.newParentId,
|
||||
x: operation.data.newPosition.x,
|
||||
y: operation.data.newPosition.y,
|
||||
},
|
||||
}
|
||||
|
||||
case 'apply-diff':
|
||||
return {
|
||||
operation: 'apply-diff',
|
||||
target: 'workflow',
|
||||
payload: {
|
||||
diffAnalysis: operation.data.diffAnalysis,
|
||||
},
|
||||
}
|
||||
|
||||
case 'accept-diff':
|
||||
return {
|
||||
operation: 'accept-diff',
|
||||
target: 'workflow',
|
||||
payload: {
|
||||
diffAnalysis: operation.data.diffAnalysis,
|
||||
},
|
||||
}
|
||||
|
||||
case 'reject-diff':
|
||||
return {
|
||||
operation: 'reject-diff',
|
||||
target: 'workflow',
|
||||
payload: {
|
||||
diffAnalysis: operation.data.diffAnalysis,
|
||||
},
|
||||
}
|
||||
|
||||
case 'batch-toggle-enabled':
|
||||
return {
|
||||
operation: 'batch-toggle-enabled',
|
||||
target: 'blocks',
|
||||
payload: {
|
||||
blockIds: operation.data.blockIds,
|
||||
previousStates: operation.data.previousStates,
|
||||
},
|
||||
}
|
||||
|
||||
case 'batch-toggle-handles':
|
||||
return {
|
||||
operation: 'batch-toggle-handles',
|
||||
target: 'blocks',
|
||||
payload: {
|
||||
blockIds: operation.data.blockIds,
|
||||
previousStates: operation.data.previousStates,
|
||||
},
|
||||
}
|
||||
|
||||
default: {
|
||||
const exhaustiveCheck: never = operation
|
||||
throw new Error(`Unhandled operation type: ${(exhaustiveCheck as Operation).type}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user