MCPcopy Index your code
hub / github.com/simstudioai/sim / createInverseOperation

Function createInverseOperation

apps/sim/stores/undo-redo/utils.ts:27–208  ·  view source on GitHub ↗
(operation: Operation)

Source from the content-addressed store, hash-verified

25}
26
27export function createInverseOperation(operation: Operation): Operation {
28 switch (operation.type) {
29 case UNDO_REDO_OPERATIONS.BATCH_ADD_BLOCKS: {
30 const op = operation as BatchAddBlocksOperation
31 return {
32 ...operation,
33 type: UNDO_REDO_OPERATIONS.BATCH_REMOVE_BLOCKS,
34 data: {
35 blockSnapshots: op.data.blockSnapshots,
36 edgeSnapshots: op.data.edgeSnapshots,
37 subBlockValues: op.data.subBlockValues,
38 },
39 } as BatchRemoveBlocksOperation
40 }
41
42 case UNDO_REDO_OPERATIONS.BATCH_REMOVE_BLOCKS: {
43 const op = operation as BatchRemoveBlocksOperation
44 return {
45 ...operation,
46 type: UNDO_REDO_OPERATIONS.BATCH_ADD_BLOCKS,
47 data: {
48 blockSnapshots: op.data.blockSnapshots,
49 edgeSnapshots: op.data.edgeSnapshots,
50 subBlockValues: op.data.subBlockValues,
51 },
52 } as BatchAddBlocksOperation
53 }
54
55 case UNDO_REDO_OPERATIONS.BATCH_ADD_EDGES: {
56 const op = operation as BatchAddEdgesOperation
57 return {
58 ...operation,
59 type: UNDO_REDO_OPERATIONS.BATCH_REMOVE_EDGES,
60 data: {
61 edgeSnapshots: op.data.edgeSnapshots,
62 },
63 } as BatchRemoveEdgesOperation
64 }
65
66 case UNDO_REDO_OPERATIONS.BATCH_REMOVE_EDGES: {
67 const op = operation as BatchRemoveEdgesOperation
68 return {
69 ...operation,
70 type: UNDO_REDO_OPERATIONS.BATCH_ADD_EDGES,
71 data: {
72 edgeSnapshots: op.data.edgeSnapshots,
73 },
74 } as BatchAddEdgesOperation
75 }
76
77 case UNDO_REDO_OPERATIONS.BATCH_MOVE_BLOCKS: {
78 const op = operation as BatchMoveBlocksOperation
79 return {
80 ...operation,
81 type: UNDO_REDO_OPERATIONS.BATCH_MOVE_BLOCKS,
82 data: {
83 moves: op.data.moves.map((m) => ({
84 blockId: m.blockId,

Callers 1

utils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected