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

Function patchRowIdInEntry

apps/sim/stores/table/store.ts:16–81  ·  view source on GitHub ↗
(entry: UndoEntry, oldRowId: string, newRowId: string)

Source from the content-addressed store, hash-verified

14let undoRedoInProgress = false
15
16function patchRowIdInEntry(entry: UndoEntry, oldRowId: string, newRowId: string): UndoEntry {
17 const { action } = entry
18 switch (action.type) {
19 case 'update-cell':
20 if (action.rowId === oldRowId) {
21 return { ...entry, action: { ...action, rowId: newRowId } }
22 }
23 break
24 case 'clear-cells': {
25 const hasMatch = action.cells.some((c) => c.rowId === oldRowId)
26 if (hasMatch) {
27 const patched = action.cells.map((c) =>
28 c.rowId === oldRowId ? { ...c, rowId: newRowId } : c
29 )
30 return { ...entry, action: { ...action, cells: patched } }
31 }
32 break
33 }
34 case 'update-cells': {
35 const hasMatch = action.cells.some((c) => c.rowId === oldRowId)
36 if (hasMatch) {
37 const patched = action.cells.map((c) =>
38 c.rowId === oldRowId ? { ...c, rowId: newRowId } : c
39 )
40 return { ...entry, action: { ...action, cells: patched } }
41 }
42 break
43 }
44 case 'create-row':
45 if (action.rowId === oldRowId) {
46 return { ...entry, action: { ...action, rowId: newRowId } }
47 }
48 break
49 case 'create-rows': {
50 const hasMatch = action.rows.some((r) => r.rowId === oldRowId)
51 if (hasMatch) {
52 const patched = action.rows.map((r) =>
53 r.rowId === oldRowId ? { ...r, rowId: newRowId } : r
54 )
55 return { ...entry, action: { ...action, rows: patched } }
56 }
57 break
58 }
59 case 'delete-rows': {
60 const hasMatch = action.rows.some((r) => r.rowId === oldRowId)
61 if (hasMatch) {
62 const patched = action.rows.map((r) =>
63 r.rowId === oldRowId ? { ...r, rowId: newRowId } : r
64 )
65 return { ...entry, action: { ...action, rows: patched } }
66 }
67 break
68 }
69 case 'delete-column': {
70 const hasMatch = action.cellData.some((c) => c.rowId === oldRowId)
71 if (hasMatch) {
72 const patched = action.cellData.map((c) =>
73 c.rowId === oldRowId ? { ...c, rowId: newRowId } : c

Callers 1

store.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected