Add deprecated warnings

This commit is contained in:
世界
2024-11-04 23:04:58 +08:00
parent c7d9b49de7
commit 59aebddaa4
4 changed files with 52 additions and 14 deletions
@@ -83,6 +83,7 @@ public struct DashboardView: View {
}
struct DashboardView1: View {
@Environment(\.openURL) var openURL
@EnvironmentObject private var environments: ExtensionEnvironments
@EnvironmentObject private var profile: ExtensionProfile
@State private var alert: Alert?
@@ -100,6 +101,9 @@ public struct DashboardView: View {
if newValue == .disconnecting || newValue == .connected {
Task {
await checkServiceError()
if newValue == .connected {
await checkDeprecatedNotes()
}
}
} else if newValue == .connecting {
notStarted = true
@@ -115,6 +119,40 @@ public struct DashboardView: View {
}
}
private nonisolated func checkDeprecatedNotes() async {
do {
let reports = try LibboxNewStandaloneCommandClient()!.getDeprecatedNotes()
if reports.hasNext() {
await MainActor.run {
loopShowDeprecateNotes(reports)
}
}
} catch {
await MainActor.run {
alert = Alert(error)
}
}
}
@MainActor
private func loopShowDeprecateNotes(_ reports: any LibboxDeprecatedNoteIteratorProtocol) {
if reports.hasNext() {
let report = reports.next()!
NSLog("show next")
alert = Alert(
title: Text("Deprecated Warning"),
message: Text(report.message()),
primaryButton: .cancel(Text("Ok")) {
loopShowDeprecateNotes(reports)
},
secondaryButton: .default(Text("Documentation")) {
openURL(URL(string: report.migrationLink)!)
loopShowDeprecateNotes(reports)
}
)
}
}
private nonisolated func checkServiceError() async {
var error: NSError?
let message = LibboxReadServiceError(&error)
@@ -52,6 +52,7 @@ public struct GroupView: View {
}
.alertBinding($alert)
.padding([.top, .bottom], 8)
.animation(.easeInOut, value: group.isExpand)
}
public var body: some View {