Fix showing deprecated warnings without link

This commit is contained in:
世界
2025-02-20 22:27:56 +08:00
parent 2fd7bdc822
commit 7d3e1e879f
@@ -141,23 +141,36 @@ public struct DashboardView: View {
private func loopShowDeprecateNotes(_ reports: any LibboxDeprecatedNoteIteratorProtocol) { private func loopShowDeprecateNotes(_ reports: any LibboxDeprecatedNoteIteratorProtocol) {
if reports.hasNext() { if reports.hasNext() {
let report = reports.next()! let report = reports.next()!
alert = Alert( if report.migrationLink.isEmpty {
title: Text("Deprecated Warning"), alert = Alert(
message: Text(report.message()), title: Text("Deprecated Warning"),
primaryButton: .default(Text("Documentation")) { message: Text(report.message()),
openURL(URL(string: report.migrationLink)!) dismissButton: .cancel(Text("Ok")) {
Task.detached { Task.detached {
try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC) try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC)
await loopShowDeprecateNotes(reports) await loopShowDeprecateNotes(reports)
}
} }
}, )
secondaryButton: .cancel(Text("Ok")) { } else {
Task.detached { alert = Alert(
try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC) title: Text("Deprecated Warning"),
await loopShowDeprecateNotes(reports) message: Text(report.message()),
primaryButton: .default(Text("Documentation")) {
openURL(URL(string: report.migrationLink)!)
Task.detached {
try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC)
await loopShowDeprecateNotes(reports)
}
},
secondaryButton: .cancel(Text("Ok")) {
Task.detached {
try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC)
await loopShowDeprecateNotes(reports)
}
} }
} )
) }
} }
} }