Skip to content

Commit fe19e77

Browse files
committed
fix: convert PluginEntry to stored properties, fix external metatype dispatch
1 parent f224cf6 commit fe19e77

3 files changed

Lines changed: 7 additions & 23 deletions

File tree

TablePro/Core/Plugins/PluginModels.swift

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ struct PluginEntry: Identifiable {
1616
let pluginDescription: String
1717
let capabilities: [PluginCapability]
1818
var isEnabled: Bool
19+
20+
let databaseTypeId: String?
21+
let additionalTypeIds: [String]
22+
let pluginIconName: String
23+
let defaultPort: Int?
1924
}
2025

2126
enum PluginSource {
@@ -24,26 +29,6 @@ enum PluginSource {
2429
}
2530

2631
extension PluginEntry {
27-
var driverPlugin: (any DriverPlugin.Type)? {
28-
bundle.principalClass as? any DriverPlugin.Type
29-
}
30-
31-
var iconName: String {
32-
driverPlugin?.iconName ?? "puzzlepiece"
33-
}
34-
35-
var databaseTypeId: String? {
36-
driverPlugin?.databaseTypeId
37-
}
38-
39-
var additionalTypeIds: [String] {
40-
driverPlugin?.additionalDatabaseTypeIds ?? []
41-
}
42-
43-
var defaultPort: Int? {
44-
driverPlugin?.defaultPort
45-
}
46-
4732
var exportPlugin: (any ExportFormatPlugin.Type)? {
4833
bundle.principalClass as? any ExportFormatPlugin.Type
4934
}

TablePro/Views/Connection/ConnectionFormView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,7 @@ struct ConnectionFormView: View { // swiftlint:disable:this type_body_length
828828
}
829829

830830
private var filePathPrompt: String {
831-
let extensions = PluginManager.shared.driverPlugin(for: type)
832-
.map { Swift.type(of: $0).fileExtensions } ?? []
831+
let extensions = PluginManager.shared.fileExtensions(for: type)
833832
let ext = (extensions.first ?? "db")
834833
.trimmingCharacters(in: CharacterSet(charactersIn: ". "))
835834
guard !ext.isEmpty else { return "/path/to/database.db" }

TablePro/Views/Settings/Plugins/InstalledPluginsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ struct InstalledPluginsView: View {
146146
@ViewBuilder
147147
private func pluginRow(_ plugin: PluginEntry) -> some View {
148148
HStack(spacing: 8) {
149-
PluginIconView(name: plugin.iconName)
149+
PluginIconView(name: plugin.pluginIconName)
150150
.font(.title3)
151151
.frame(width: 24, height: 24)
152152
.foregroundStyle(plugin.isEnabled ? .secondary : .tertiary)

0 commit comments

Comments
 (0)