Refactor Alerts
This commit is contained in:
@@ -54,7 +54,7 @@ public struct ConnectionListView: View {
|
||||
#if os(macOS)
|
||||
.searchable(text: $viewModel.searchText)
|
||||
#endif
|
||||
.alertBinding($viewModel.alert)
|
||||
.alert($viewModel.alert)
|
||||
.onAppear {
|
||||
viewModel.connect()
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ConnectionListViewModel: BaseViewModel {
|
||||
private var saveStateFilterTask: Task<Void, Never>?
|
||||
private var saveSortTask: Task<Void, Never>?
|
||||
|
||||
public override init() {
|
||||
override public init() {
|
||||
connectionStateFilter = .active
|
||||
connectionSort = .byDate
|
||||
super.init()
|
||||
@@ -70,7 +70,7 @@ public class ConnectionListViewModel: BaseViewModel {
|
||||
do {
|
||||
try LibboxNewStandaloneCommandClient()!.closeConnections()
|
||||
} catch {
|
||||
alert = Alert(error)
|
||||
alert = AlertState(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public struct ConnectionView: View {
|
||||
LibboxFormatDuration(Int64((closedAt.timeIntervalSince1970 - createdAt.timeIntervalSince1970) * 1000))
|
||||
}
|
||||
|
||||
@State private var alert: Alert?
|
||||
@State private var alert: AlertState?
|
||||
|
||||
public var body: some View {
|
||||
FormNavigationLink {
|
||||
@@ -86,7 +86,7 @@ public struct ConnectionView: View {
|
||||
#if !os(tvOS)
|
||||
.buttonStyle(.borderless)
|
||||
#endif
|
||||
.alertBinding($alert)
|
||||
.alert($alert)
|
||||
.contextMenu {
|
||||
if connection.closedAt == nil {
|
||||
Button("Close", role: .destructive) {
|
||||
@@ -114,7 +114,7 @@ public struct ConnectionView: View {
|
||||
try await LibboxNewStandaloneCommandClient()!.closeConnection(connection.id)
|
||||
} catch {
|
||||
await MainActor.run {
|
||||
alert = Alert(error)
|
||||
alert = AlertState(error: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user