You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replaced 9 sidebar action notifications with direct coordinator calls and `@FocusedValue` routing. Context menu actions call coordinator directly. Menu bar uses `actions?.copyTableNames()` and `actions?.truncateTables()` via `@FocusedValue`.
126
114
127
-
```swift
128
-
// Define focused value
129
-
structSidebarActionsKey: FocusedValueKey {
130
-
typealiasValue= SidebarViewModel
131
-
}
115
+
-[x]`copyTableNames` — menu → `actions?.copyTableNames()` → `coordinator.sidebarViewModel.copySelectedTableNames()`
116
+
-[x]`truncateTables` — menu → `actions?.truncateTables()` → `coordinator.sidebarViewModel.batchToggleTruncate()`
117
+
-[x]`clearSelection` — dead (no sender), removed both subscribers
-[x]`showTableStructure` — context menu → `coordinator?.openTableTab(_, showStructure:)`
120
+
-[x]`editViewDefinition` — context menu → `coordinator?.editViewDefinition(_:)`
121
+
-[x]`createView` — context menu → `coordinator?.createView()`
122
+
-[x]`exportTables` — context menu → `coordinator?.openExportDialog()`
123
+
-[x]`importTables` — context menu → `coordinator?.openImportDialog()`
132
124
133
-
extensionFocusedValues {
134
-
var sidebarActions: SidebarViewModel? { ... }
135
-
}
136
-
137
-
// In SidebarView
138
-
.focusedValue(\.sidebarActions, viewModel)
139
-
140
-
// In menu
141
-
Button("Copy Table Names") {
142
-
focusedSidebarActions?.copySelectedTableNames()
143
-
}
144
-
```
125
+
Also extracted `createView()`, `editViewDefinition(_:)`, `openExportDialog()`, `openImportDialog()` from `MainContentCommandActions` into `MainContentCoordinator+SidebarActions.swift`. Removed all notification infrastructure from `SidebarViewModel` (`import Combine`, `cancellables`, `setupNotifications()`).
145
126
146
127
---
147
128
148
129
## Phase 5: Replace Structure View Notifications with Coordinator Pattern
149
130
150
-
**Status:**Not started
131
+
**Status:**Done
151
132
152
-
`MainContentCommandActions` routes commands to `TableStructureView`via notifications because the structure view is deeply embedded and not directly accessible.
133
+
Created `StructureViewActionHandler` class with closure properties for each action. `TableStructureView`wires closures in `.onAppear` and registers handler with coordinator. Senders call `coordinator.structureActions?.method?()` instead of posting notifications.
153
134
154
-
### Notifications to replace:
135
+
### Notifications replaced:
155
136
156
-
-[]`copySelectedRows` (structure path)
157
-
-[]`pasteRows` (structure path)
158
-
-[]`undoChange`(structure path)
159
-
-[]`redoChange`(structure path)
160
-
-[]`saveStructureChanges`
161
-
-[]`previewStructureSQL`
137
+
-[x]`copySelectedRows` (structure path) — now `structureActions?.copyRows?()`
138
+
-[x]`pasteRows` (structure path) — now `structureActions?.pasteRows?()`
139
+
-[x]`undoChange`— removed notification name, now `structureActions?.undo?()`
140
+
-[x]`redoChange`— removed notification name, now `structureActions?.redo?()`
141
+
-[x]`saveStructureChanges` — removed notification name, now `structureActions?.saveChanges?()`
142
+
-[x]`previewStructureSQL` — removed notification name, now `structureActions?.previewSQL?()`
162
143
163
-
### Strategy:
144
+
### Files changed:
164
145
165
-
Create a `StructureViewActions` protocol/class that `TableStructureView` registers with the coordinator. The coordinator calls methods directly instead of broadcasting.
146
+
-**New:**`Views/Structure/StructureViewActionHandler.swift` — action handler class
147
+
-**Modified:**`MainContentCoordinator.swift` — added `weak var structureActions`
148
+
-**Modified:**`TableStructureView.swift` — wire closures on appear, removed 6 `.onReceive` handlers
149
+
-**Modified:**`MainEditorContentView.swift` — pass coordinator to `TableStructureView`
150
+
-**Modified:**`MainContentCommandActions.swift` — 6 notification posts → direct calls
151
+
-**Modified:**`MainContentCoordinator+SQLPreview.swift` — notification post → direct call
152
+
-**Modified:**`TableProApp.swift` — removed 4 notification name definitions
0 commit comments