mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Restore alerts on Edit > Delete, no-network failure
This commit is contained in:
parent
b788994144
commit
5dabe97db4
@ -65,6 +65,17 @@ struct ContentView: View {
|
||||
.disabled(!model.account.isLoggedIn)
|
||||
.padding(.leading, sidebarIsHidden ? 8 : 0)
|
||||
.animation(.linear)
|
||||
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||
Alert(
|
||||
title: Text("Connection Error"),
|
||||
message: Text("""
|
||||
There is no internet connection at the moment. Please reconnect or try again later.
|
||||
"""),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
ToolbarItem(placement: .status) {
|
||||
if let selectedPost = model.selectedPost {
|
||||
@ -93,33 +104,6 @@ struct ContentView: View {
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.environmentObject(model)
|
||||
.alert(isPresented: $model.isPresentingDeleteAlert) {
|
||||
Alert(
|
||||
title: Text("Delete Post?"),
|
||||
message: Text("This action cannot be undone."),
|
||||
primaryButton: .destructive(Text("Delete"), action: {
|
||||
if let postToDelete = model.postToDelete {
|
||||
model.selectedPost = nil
|
||||
DispatchQueue.main.async {
|
||||
model.posts.remove(postToDelete)
|
||||
}
|
||||
model.postToDelete = nil
|
||||
}
|
||||
}),
|
||||
secondaryButton: .cancel() {
|
||||
model.postToDelete = nil
|
||||
}
|
||||
)
|
||||
}
|
||||
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||
Alert(
|
||||
title: Text("Connection Error"),
|
||||
message: Text("There is no internet connection at the moment. Please reconnect or try again later"),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
#if os(iOS)
|
||||
EmptyView()
|
||||
@ -131,6 +115,15 @@ struct ContentView: View {
|
||||
.environmentObject(model)
|
||||
}
|
||||
)
|
||||
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||
Alert(
|
||||
title: Text("Connection Error"),
|
||||
message: Text("There is no internet connection at the moment. Please reconnect or try again later."),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
)
|
||||
})
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,24 @@ struct PostListFilteredView: View {
|
||||
}
|
||||
})
|
||||
}
|
||||
.alert(isPresented: $model.isPresentingDeleteAlert) {
|
||||
Alert(
|
||||
title: Text("Delete Post?"),
|
||||
message: Text("This action cannot be undone."),
|
||||
primaryButton: .destructive(Text("Delete"), action: {
|
||||
if let postToDelete = model.postToDelete {
|
||||
model.selectedPost = nil
|
||||
DispatchQueue.main.async {
|
||||
model.posts.remove(postToDelete)
|
||||
}
|
||||
model.postToDelete = nil
|
||||
}
|
||||
}),
|
||||
secondaryButton: .cancel() {
|
||||
model.postToDelete = nil
|
||||
}
|
||||
)
|
||||
}
|
||||
.onAppear(perform: {
|
||||
self.postCount = fetchRequest.wrappedValue.count
|
||||
})
|
||||
@ -104,6 +122,7 @@ struct PostListFilteredView: View {
|
||||
|
||||
func delete(_ post: WFAPost) {
|
||||
DispatchQueue.main.async {
|
||||
model.selectedPost = nil
|
||||
model.posts.remove(post)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user