mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Multiline timezone field
handle nil in firmware web methods
This commit is contained in:
parent
8156777fea
commit
110c9dad4a
2 changed files with 18 additions and 4 deletions
|
|
@ -90,7 +90,7 @@ struct DeviceConfig: View {
|
|||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Label("Time Zone", systemImage: "clock.badge.exclamationmark")
|
||||
TextField("Time Zone", text: $tzdef)
|
||||
TextField("Time Zone", text: $tzdef, axis: .vertical)
|
||||
.foregroundColor(.gray)
|
||||
.onChange(of: tzdef, perform: { _ in
|
||||
let totalBytes = tzdef.utf8.count
|
||||
|
|
@ -100,6 +100,7 @@ struct DeviceConfig: View {
|
|||
}
|
||||
})
|
||||
.foregroundColor(.gray)
|
||||
|
||||
}
|
||||
.keyboardType(.default)
|
||||
.disableAutocorrection(true)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,15 @@ class Api : ObservableObject{
|
|||
DispatchQueue.main.async {
|
||||
completion(deviceHardware)
|
||||
}
|
||||
|
||||
if let data = data {
|
||||
if let deviceHardware = try? JSONDecoder().decode([DeviceHardware].self, from: data) {
|
||||
DispatchQueue.main.async {
|
||||
completion(deviceHardware)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
|
||||
|
|
@ -67,9 +76,13 @@ class Api : ObservableObject{
|
|||
return
|
||||
}
|
||||
URLSession.shared.dataTask(with: url) { data, response, error in
|
||||
let firmwareReleases = try! JSONDecoder().decode(FirmwareReleases.self, from: data!)
|
||||
DispatchQueue.main.async {
|
||||
completion(firmwareReleases)
|
||||
if let data = data {
|
||||
if let firmwareReleases = try? JSONDecoder().decode(FirmwareReleases.self, from: data) {
|
||||
DispatchQueue.main.async {
|
||||
completion(firmwareReleases)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue