Files
luma/Sources/LumaCore/Models/InstalledPackage.swift
Ole André Vadla Ravnås d933686c4f luma: Reset alias on select, hoist to LumaCore
Selecting a search result now always re-populates the global alias
from the new package's default (or clears the field when there
isn't one), instead of only filling it when the field was empty.
That previously left a stale alias like "ObjC" behind when the user
switched from a bridge package to an ordinary one.

While here, move defaultGlobalAlias into LumaCore on InstalledPackage
where the rest of the package business logic lives, so the SwiftUI
and GTK frontends share a single table.
2026-04-19 15:53:05 +02:00

48 lines
1.3 KiB
Swift

import Foundation
import GRDB
public struct InstalledPackage: Codable, Identifiable, Sendable, FetchableRecord, PersistableRecord {
public static let databaseTableName = "installed_package"
public var id: UUID
public var packagesStateID: UUID
public var name: String
public var version: String
public var globalAlias: String?
public var addedAt: Date
enum CodingKeys: String, CodingKey {
case id
case packagesStateID = "packages_state_id"
case name
case version
case globalAlias = "global_alias"
case addedAt = "added_at"
}
public init(
id: UUID = UUID(),
packagesStateID: UUID = UUID(),
name: String,
version: String,
globalAlias: String? = nil,
addedAt: Date = .now
) {
self.id = id
self.packagesStateID = packagesStateID
self.name = name
self.version = version
self.globalAlias = globalAlias
self.addedAt = addedAt
}
public static func defaultGlobalAlias(forPackageName name: String) -> String? {
switch name {
case "frida-objc-bridge": return "ObjC"
case "frida-java-bridge": return "Java"
case "frida-swift-bridge": return "Swift"
default: return nil
}
}
}