Skip to content

Commit f5eb348

Browse files
committed
chore: address low-priority cleanup items
- Replace deprecated .cornerRadius() with .clipShape(RoundedRectangle()) in 8 files - Remove dead nonisolated deinit from AppDelegate - Replace DispatchQueue.main.async with Task in @mainactor SQLEditorCoordinator - Add @mainactor to UserDefaults+RecentDatabases.trackDatabaseAccess - Add Logger warning on invalid hex color fallback in Color+Hex - Document AppLanguage.apply() side effect - Use ThemeEngine typography in ConnectionSwitcherPopover (replace hardcoded sizes)
1 parent f0417dc commit f5eb348

File tree

14 files changed

+26
-25
lines changed

14 files changed

+26
-25
lines changed

TablePro/AppDelegate.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,4 @@ class AppDelegate: NSObject, NSApplicationDelegate {
118118
func applicationWillTerminate(_ notification: Notification) {
119119
SSHTunnelManager.shared.terminateAllProcessesSync()
120120
}
121-
122-
nonisolated deinit {
123-
NotificationCenter.default.removeObserver(self)
124-
}
125121
}

TablePro/Extensions/Color+Hex.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
// TablePro
44
//
55

6+
import os
67
import SwiftUI
78

89
extension Color {
10+
private static let logger = Logger(subsystem: "com.TablePro", category: "Color+Hex")
11+
912
init(hex: String) {
1013
let cleaned = hex
1114
.trimmingCharacters(in: .whitespacesAndNewlines)
1215
.trimmingCharacters(in: CharacterSet(charactersIn: "#"))
1316

1417
guard cleaned.count == 6, let rgbValue = UInt64(cleaned, radix: 16) else {
18+
Self.logger.warning("Invalid hex color: \(hex)")
1519
self = .gray
1620
return
1721
}

TablePro/Extensions/UserDefaults+RecentDatabases.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension UserDefaults {
2525
/// - Parameters:
2626
/// - database: Database name to track
2727
/// - connectionId: The connection UUID
28-
func trackDatabaseAccess(_ database: String, for connectionId: UUID) {
28+
@MainActor func trackDatabaseAccess(_ database: String, for connectionId: UUID) {
2929
var dict = (dictionary(forKey: Self.recentDatabasesKey) as? [String: [String]]) ?? [:]
3030
var recent = dict[connectionId.uuidString] ?? []
3131

TablePro/Models/Settings/AppSettings.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum AppLanguage: String, Codable, CaseIterable, Identifiable {
4646
}
4747
}
4848

49+
// Side effect: sets UserDefaults AppleLanguages. Consider moving to AppSettingsManager.
4950
func apply() {
5051
if self == .system {
5152
UserDefaults.standard.removeObject(forKey: "AppleLanguages")

TablePro/Views/Components/SectionHeaderView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct SectionHeaderView<Actions: View>: View {
8181
ThemeEngine.shared.colors.ui.controlBackgroundSwiftUI.opacity(0.5) :
8282
Color.clear
8383
)
84-
.cornerRadius(ThemeEngine.shared.activeTheme.cornerRadius.medium)
84+
.clipShape(RoundedRectangle(cornerRadius: ThemeEngine.shared.activeTheme.cornerRadius.medium))
8585
.contentShape(Rectangle())
8686
}
8787
}

TablePro/Views/DatabaseSwitcher/DatabaseSwitcherSheet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct DatabaseSwitcherSheet: View {
170170
.padding(.horizontal, 8)
171171
.padding(.vertical, 6)
172172
.background(Color(nsColor: .controlBackgroundColor))
173-
.cornerRadius(6)
173+
.clipShape(RoundedRectangle(cornerRadius: 6))
174174

175175
// Refresh
176176
Button(action: {

TablePro/Views/Editor/SQLEditorCoordinator.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ final class SQLEditorCoordinator: TextViewCoordinator {
8080

8181
// Deferred to next run loop because prepareCoordinator runs during
8282
// TextViewController.init, before the view hierarchy is fully loaded.
83-
DispatchQueue.main.async { [weak self] in
83+
Task { @MainActor [weak self] in
8484
guard let self else { return }
8585
self.fixFindPanelHitTesting(controller: controller)
8686
self.applyHorizontalScrollFix(controller: controller)
@@ -98,7 +98,7 @@ final class SQLEditorCoordinator: TextViewCoordinator {
9898
vimEngine?.invalidateLineCache()
9999

100100
// Notify inline suggestion manager immediately (lightweight)
101-
DispatchQueue.main.async { [weak self] in
101+
Task { @MainActor [weak self] in
102102
self?.inlineSuggestionManager?.handleTextChange()
103103
self?.vimCursorManager?.updatePosition()
104104
}
@@ -133,7 +133,7 @@ final class SQLEditorCoordinator: TextViewCoordinator {
133133
guard let range = newPositions.first?.range, range.location != NSNotFound else { return }
134134

135135
// Defer to next run loop to let EmphasisManager finish its work first.
136-
DispatchQueue.main.async { [weak controller] in
136+
Task { @MainActor [weak controller] in
137137
controller?.textView.scrollToRange(range)
138138
}
139139
}
@@ -297,7 +297,7 @@ final class SQLEditorCoordinator: TextViewCoordinator {
297297
) { [weak self, weak controller] _ in
298298
guard let self, let controller else { return }
299299
// Defer so it runs AFTER reloadUI() → styleTextView()
300-
DispatchQueue.main.async { [weak self, weak controller] in
300+
Task { @MainActor [weak self, weak controller] in
301301
guard let self, let controller else { return }
302302
self.setHorizontalScrollProperties(controller: controller)
303303
self.handleVimSettingsChange(controller: controller)

TablePro/Views/Filter/FilterRowView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct FilterRowView: View {
137137
.padding(.horizontal, 8)
138138
.padding(.vertical, 5)
139139
.background(Color(nsColor: .controlBackgroundColor))
140-
.cornerRadius(4)
140+
.clipShape(RoundedRectangle(cornerRadius: 4))
141141
.overlay(
142142
RoundedRectangle(cornerRadius: 4)
143143
.stroke(Color(nsColor: .separatorColor), lineWidth: 0.5)
@@ -174,7 +174,7 @@ struct FilterRowView: View {
174174
.padding(.horizontal, 8)
175175
.padding(.vertical, 5)
176176
.background(Color(nsColor: .controlBackgroundColor))
177-
.cornerRadius(4)
177+
.clipShape(RoundedRectangle(cornerRadius: 4))
178178
.overlay(
179179
RoundedRectangle(cornerRadius: 4)
180180
.stroke(Color(nsColor: .separatorColor), lineWidth: 0.5)
@@ -202,7 +202,7 @@ struct FilterRowView: View {
202202
.padding(.horizontal, 8)
203203
.padding(.vertical, 5)
204204
.background(Color(nsColor: .textBackgroundColor))
205-
.cornerRadius(4)
205+
.clipShape(RoundedRectangle(cornerRadius: 4))
206206
.overlay(
207207
RoundedRectangle(cornerRadius: 4)
208208
.stroke(Color(nsColor: .separatorColor), lineWidth: 0.5)
@@ -217,7 +217,7 @@ struct FilterRowView: View {
217217
.padding(.horizontal, 8)
218218
.padding(.vertical, 5)
219219
.background(Color(nsColor: .textBackgroundColor))
220-
.cornerRadius(4)
220+
.clipShape(RoundedRectangle(cornerRadius: 4))
221221
.overlay(
222222
RoundedRectangle(cornerRadius: 4)
223223
.stroke(Color(nsColor: .separatorColor), lineWidth: 0.5)
@@ -241,7 +241,7 @@ struct FilterRowView: View {
241241
.padding(.horizontal, 8)
242242
.padding(.vertical, 5)
243243
.background(Color(nsColor: .textBackgroundColor))
244-
.cornerRadius(4)
244+
.clipShape(RoundedRectangle(cornerRadius: 4))
245245
.overlay(
246246
RoundedRectangle(cornerRadius: 4)
247247
.stroke(Color(nsColor: .separatorColor), lineWidth: 0.5)

TablePro/Views/Filter/SQLPreviewSheet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct SQLPreviewSheet: View {
3939
}
4040
.frame(maxHeight: 180)
4141
.background(Color(nsColor: .textBackgroundColor))
42-
.cornerRadius(6)
42+
.clipShape(RoundedRectangle(cornerRadius: 6))
4343
.overlay(
4444
RoundedRectangle(cornerRadius: 6)
4545
.stroke(Color(nsColor: .separatorColor), lineWidth: 0.5)

TablePro/Views/Import/ImportDialog.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ struct ImportDialog: View {
214214

215215
SQLCodePreview(text: $filePreview)
216216
.frame(height: availableFormats.count > 1 ? 220 : 280)
217-
.cornerRadius(6)
217+
.clipShape(RoundedRectangle(cornerRadius: 6))
218218
.overlay(
219219
RoundedRectangle(cornerRadius: 6)
220220
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)

0 commit comments

Comments
 (0)