mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-15 20:10:30 +00:00
safety features
This commit is contained in:
parent
1fefbc4fc6
commit
80945fe811
2 changed files with 14 additions and 8 deletions
|
|
@ -23,6 +23,7 @@ func httpGet(_ urlString: String, result: @escaping (String?) -> Void){
|
|||
|
||||
if let error = error {
|
||||
print("Error: \(error.localizedDescription)")
|
||||
result(nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -75,13 +76,16 @@ func UpdateRetrieval() -> Bool{
|
|||
}
|
||||
let ver = try! String(contentsOfFile: fileURL.path)
|
||||
let urlString = "https://raw.githubusercontent.com/0-Blu/StikJIT/refs/heads/main/version.txt"
|
||||
var res = false;
|
||||
var res = false
|
||||
httpGet(urlString) { result in
|
||||
if (ver != result){
|
||||
res = true;
|
||||
}
|
||||
if let fc = result {
|
||||
if (ver != fc){
|
||||
res = true
|
||||
}
|
||||
} // if nil then request failed so we won't throw an error
|
||||
|
||||
}
|
||||
return res;
|
||||
return res
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -130,9 +134,11 @@ struct HeartbeatApp: App {
|
|||
alert_title = "Update Avaliable!"
|
||||
let urlString = "https://raw.githubusercontent.com/0-Blu/StikJIT/refs/heads/main/version.txt"
|
||||
httpGet(urlString) { result in
|
||||
alert_string = "Update to: v" + result!
|
||||
if result == nil { return }
|
||||
alert_string = "Update to: version \(result!)!"
|
||||
show_alert = true
|
||||
}
|
||||
show_alert = true
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ struct SettingsView: View {
|
|||
HStack {
|
||||
Spacer()
|
||||
let fileURL = URL.documentsDirectory.appendingPathComponent("version.txt")
|
||||
let ver = try! String(contentsOfFile: fileURL.path)
|
||||
let ver = (try? String(contentsOfFile: fileURL.path)) ?? "-"
|
||||
Text("Version \(ver) • iOS \(UIDevice.current.systemVersion)")
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary.opacity(0.8))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue