Make cancel the default action in the delete-confirmation alert

This commit is contained in:
Angelo Stavrow 2020-12-01 09:58:04 -05:00
parent c1be327694
commit 68fd0c91e7
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -90,7 +90,10 @@ struct PostListFilteredView: View {
Alert(
title: Text("Delete Post?"),
message: Text("This action cannot be undone."),
primaryButton: .destructive(Text("Delete"), action: {
primaryButton: .cancel() {
model.postToDelete = nil
},
secondaryButton: .destructive(Text("Delete"), action: {
if let postToDelete = model.postToDelete {
model.selectedPost = nil
DispatchQueue.main.async {
@ -99,10 +102,7 @@ struct PostListFilteredView: View {
}
model.postToDelete = nil
}
}),
secondaryButton: .cancel() {
model.postToDelete = nil
}
})
)
}
.onAppear(perform: {