Skip to content

Commit

Permalink
Fix BundlePickerView
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jan 16, 2025
1 parent ec58c5b commit d1619cc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
28 changes: 25 additions & 3 deletions src/TrueWidget/swift/UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,32 @@ struct TimeZoneTimeSetting: Identifiable, Codable {
var abbreviation: String = "UTC"
}

struct BundleSetting: Identifiable, Codable {
final class BundleSetting: Identifiable, Codable, ObservableObject {
var id = UUID().uuidString
var show = false
var path = ""
@Published var show = false
@Published var path = ""

enum CodingKeys: String, CodingKey {
case show
case path
}

init(path: String = "", show: Bool = false) {
self.show = show
self.path = path
}

required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.path = try container.decode(String.self, forKey: .path)
self.show = try container.decode(Bool.self, forKey: .show)
}

func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(path, forKey: .path)
try container.encode(show, forKey: .show)
}
}

final class UserSettings: ObservableObject {
Expand Down
14 changes: 8 additions & 6 deletions src/TrueWidget/swift/Views/BundlePickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ struct BundlePickerView: View {
) { result in
if let url = try? result.get().first {
HelperClient.shared.proxy?.bundleVersions(paths: [url.path]) { versions in
if versions[url.path] != nil {
path = url.path
errorMessage = nil
} else {
path = ""
errorMessage = "Could not get the version of the selected file"
Task { @MainActor in
if versions[url.path] != nil {
path = url.path
errorMessage = nil
} else {
path = ""
errorMessage = "Could not get the version of the selected file"
}
}
}
return
Expand Down

0 comments on commit d1619cc

Please sign in to comment.