mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Update crash alert copy and navigate to help forum
This commit is contained in:
parent
5a1b400333
commit
efe173cfca
@ -51,18 +51,21 @@ struct WriteFreely_MultiPlatformApp: App {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.alert(isPresented: $didCrash) {
|
.alert(isPresented: $didCrash) {
|
||||||
|
var helpMsg = "Alert the humans by sharing what happened on the help forum."
|
||||||
|
if let errorMsg = UserDefaults.shared.object(forKey: WFDefaults.fatalErrorDescription) as? String {
|
||||||
|
helpMsg.append("\n\n\(errorMsg)")
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: - Confirm copy for this alert
|
// TODO: - Confirm copy for this alert
|
||||||
Alert(
|
return Alert(
|
||||||
title: Text("Crash Detected"),
|
title: Text("Crash Detected"),
|
||||||
message: Text(
|
message: Text(helpMsg),
|
||||||
UserDefaults.shared.object(forKey: WFDefaults.fatalErrorDescription) as? String ??
|
primaryButton: .default(
|
||||||
"Something went horribly wrong!"
|
Text("Let us know"), action: didPressCrashAlertButton
|
||||||
),
|
),
|
||||||
dismissButton: .default(
|
secondaryButton: .cancel(
|
||||||
Text("Dismiss"), action: {
|
Text("Dismiss"),
|
||||||
UserDefaults.shared.set(false, forKey: WFDefaults.didHaveFatalError)
|
action: resetCrashFlags
|
||||||
UserDefaults.shared.removeObject(forKey: WFDefaults.fatalErrorDescription)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -163,4 +166,19 @@ struct WriteFreely_MultiPlatformApp: App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func resetCrashFlags() {
|
||||||
|
UserDefaults.shared.set(false, forKey: WFDefaults.didHaveFatalError)
|
||||||
|
UserDefaults.shared.removeObject(forKey: WFDefaults.fatalErrorDescription)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func didPressCrashAlertButton() {
|
||||||
|
resetCrashFlags()
|
||||||
|
#if os(macOS)
|
||||||
|
NSWorkspace().open(model.helpURL)
|
||||||
|
#else
|
||||||
|
UIApplication.shared.open(model.helpURL)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user