Check for Error

This commit is contained in:
Stossy11 2025-03-28 06:42:18 +11:00
parent 8c2a104fdb
commit 4f670fa169

View file

@ -147,17 +147,17 @@ class InstalledAppsViewModel: ObservableObject {
return
}
if output.hasPrefix("{\"error\":") {
self.apps = [:]
}
print(output)
// Decode the JSON into a Swift dictionary
do {
let decoder = JSONDecoder()
let apps = try decoder.decode([String: String].self, from: jsonData)
self.apps = apps
if let app = apps.first, app.key == "error" {
self.apps = [:]
} else {
self.apps = apps
}
return
} catch {
print("Error: Failed to decode JSON - \(error)")