@@ -12,10 +12,6 @@ import SwiftUI
1212/// Sidebar view displaying list of database tables
1313struct SidebarView : View {
1414 @State private var viewModel : SidebarViewModel
15- /// Local search text for responsive typing; synced to/from shared state
16- @State private var localSearchText : String = " "
17- /// Debounce task for writing local search text to the shared state
18- @State private var searchSyncTask : Task < Void , Never > ?
1915
2016 // Keep @Binding on the view for SwiftUI change tracking.
2117 // The ViewModel stores the same bindings for write access.
@@ -56,7 +52,6 @@ struct SidebarView: View {
5652 ) {
5753 _tables = tables
5854 self . sidebarState = sidebarState
59- _localSearchText = State ( initialValue: sidebarState. searchText)
6055 _pendingTruncates = pendingTruncates
6156 _pendingDeletes = pendingDeletes
6257 let selectedBinding = Binding (
@@ -84,28 +79,11 @@ struct SidebarView: View {
8479
8580 var body : some View {
8681 VStack ( alignment: . leading, spacing: 0 ) {
87- if !tables. isEmpty {
88- searchField
89- }
9082 content
9183 }
9284 . frame ( minWidth: 280 )
93- . onChange ( of: localSearchText) { _, newValue in
94- viewModel. debouncedSearchText = newValue
95- searchSyncTask? . cancel ( )
96- searchSyncTask = Task { @MainActor in
97- try ? await Task . sleep ( nanoseconds: 150_000_000 )
98- guard !Task. isCancelled else { return }
99- if sidebarState. searchText != newValue {
100- sidebarState. searchText = newValue
101- }
102- }
103- }
10485 . onChange ( of: sidebarState. searchText) { _, newValue in
105- if localSearchText != newValue {
106- localSearchText = newValue
107- viewModel. debouncedSearchText = newValue
108- }
86+ viewModel. debouncedSearchText = newValue
10987 }
11088 . onChange ( of: tables) { _, newTables in
11189 let hasSession = DatabaseManager . shared. activeSessions [ connectionId] != nil
@@ -135,37 +113,6 @@ struct SidebarView: View {
135113 }
136114 }
137115
138- // MARK: - Search Field
139-
140- private var searchField : some View {
141- HStack ( spacing: 6 ) {
142- Image ( systemName: " magnifyingglass " )
143- . foregroundStyle ( . secondary)
144- . font ( . system( size: DesignConstants . FontSize. medium) )
145-
146- TextField ( " Filter " , text: $localSearchText)
147- . textFieldStyle ( . plain)
148- . font ( . system( size: DesignConstants . FontSize. body) )
149-
150- if !localSearchText. isEmpty {
151- Button ( action: { localSearchText = " " } ) {
152- Image ( systemName: " xmark.circle.fill " )
153- . foregroundStyle ( . secondary)
154- . font ( . system( size: DesignConstants . FontSize. medium) )
155- }
156- . buttonStyle ( . plain)
157- . accessibilityLabel ( String ( localized: " Clear table filter " ) )
158- }
159- }
160- . padding ( . horizontal, 8 )
161- . padding ( . vertical, DesignConstants . Spacing. xxs)
162- . background ( Color ( nsColor: . quaternaryLabelColor) )
163- . cornerRadius ( 6 )
164- . padding ( . horizontal, 10 )
165- . padding ( . top, 8 )
166- . padding ( . bottom, 4 )
167- }
168-
169116 // MARK: - Content States
170117
171118 @ViewBuilder
0 commit comments