From 6a33f527be4fd48801e6ccb21ac19f8aa9313118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1rady=20Mil=C3=A1n?= <61704770+MilanVarady@users.noreply.github.com> Date: Thu, 2 Jan 2025 20:41:18 +0100 Subject: [PATCH] Fix cask info key names --- .../Cask Models/CaskAdditionalInfo.swift | 20 +++++++++------ .../App View/AppView+GetInfoButton.swift | 4 +++ .../Views/Windows/CaskInfoWindowView.swift | 25 ++++++++++++------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Applite/Model/Cask Models/CaskAdditionalInfo.swift b/Applite/Model/Cask Models/CaskAdditionalInfo.swift index b569fec..428670f 100644 --- a/Applite/Model/Cask Models/CaskAdditionalInfo.swift +++ b/Applite/Model/Cask Models/CaskAdditionalInfo.swift @@ -18,31 +18,35 @@ struct CaskAdditionalInfo: Codable, Hashable { let url: URL /// Installed version let installed: String? + let bundle_version: String? let installed_time: Date? + let outdated: Bool? let auto_updates: Bool? let deprecated: Bool - let deprection_date: Date? + let deprecation_date: String? let deprecation_reason: String? let deprecation_replacement: String? let disabled: Bool - let disabled_date: Date? - let disabled_reason: String? - let disabled_replacement: String? + let disable_date: String? + let disable_reason: String? + let disable_replacement: String? static let dummy = CaskAdditionalInfo( token: "Applite", tap: "homebrew/cask", homepage: URL(string: "https://aerolite.dev/applite")!, url: URL(string: "https://github.com/milanvarady/Applite/releases/download/v1.2.5/Applite.dmg")!, installed: "1.2.5", + bundle_version: "1.2.5", installed_time: Date(timeIntervalSince1970: 1735754762), + outdated: false, auto_updates: true, deprecated: false, - deprection_date: nil, + deprecation_date: nil, deprecation_reason: nil, deprecation_replacement: nil, disabled: false, - disabled_date: nil, - disabled_reason: nil, - disabled_replacement: nil + disable_date: nil, + disable_reason: nil, + disable_replacement: nil ) } diff --git a/Applite/Views/App Views/App View/AppView+GetInfoButton.swift b/Applite/Views/App Views/App View/AppView+GetInfoButton.swift index b1ca680..0ca2084 100644 --- a/Applite/Views/App Views/App View/AppView+GetInfoButton.swift +++ b/Applite/Views/App Views/App View/AppView+GetInfoButton.swift @@ -6,6 +6,7 @@ // import SwiftUI +import OSLog extension AppView { struct GetInfoButton: View { @@ -15,6 +16,8 @@ extension AppView { @StateObject var alert = AlertManager() + private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "GetInfoButton") + var body: some View { Button { Task { @@ -23,6 +26,7 @@ extension AppView { openWindow(value: caskInfo) } catch { alert.show(error: error, title: "Failed to gather cask info") + logger.error("Failed to gather additional cask info: \(error.localizedDescription)") } } } label: { diff --git a/Applite/Views/Windows/CaskInfoWindowView.swift b/Applite/Views/Windows/CaskInfoWindowView.swift index 2db71ff..7e3e50a 100644 --- a/Applite/Views/Windows/CaskInfoWindowView.swift +++ b/Applite/Views/Windows/CaskInfoWindowView.swift @@ -56,20 +56,25 @@ struct CaskInfoWindowView: View { Row(property: "Homepage", value: info.homepage.absoluteString, url: info.homepage), Row(property: "URL", value: info.url.absoluteString, url: info.url), Row(property: "Installed Version", value: info.installed ?? "Not installed"), - Row(property: "Auto Updates", value: (info.auto_updates ?? false) ? "Yes" : "No"), - Row(property: "Deprecated", value: info.deprecated ? "Yes" : "No"), - Row(property: "Disabled", value: info.disabled ? "Yes" : "No") + Row(property: "Bundle Version", value: info.bundle_version ?? "Not installed"), + Row(property: "Auto Updates", value: (info.auto_updates ?? false) ? "Yes" : "No") ] + if let outdated = info.outdated { + result.append(Row(property: "Outdated", value: outdated ? "Yes" : "No")) + } + if let installedTime = info.installed_time { result.append(Row(property: "Installation Date", value: dateFormatter.string(from: installedTime))) } + result.append(Row(property: "Deprecated", value: info.deprecated ? "Yes" : "No")) + if info.deprecated { - if let date = info.deprection_date { + if let date = info.deprecation_date { result.append(Row(property: "Deprecation Date", - value: dateFormatter.string(from: date))) + value: date)) } if let reason = info.deprecation_reason { result.append(Row(property: "Deprecation Reason", value: reason)) @@ -79,15 +84,17 @@ struct CaskInfoWindowView: View { } } + result.append(Row(property: "Disabled", value: info.disabled ? "Yes" : "No")) + if info.disabled { - if let date = info.disabled_date { + if let date = info.disable_date { result.append(Row(property: "Disabled Date", - value: dateFormatter.string(from: date))) + value: date)) } - if let reason = info.disabled_reason { + if let reason = info.disable_reason { result.append(Row(property: "Disabled Reason", value: reason)) } - if let replacement = info.disabled_replacement { + if let replacement = info.disable_replacement { result.append(Row(property: "Disabled Replacement", value: replacement)) } }