mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Make sure to always clear the last draft when we unset the selectedPost
This commit is contained in:
parent
5dabe97db4
commit
28d3b6f831
@ -118,7 +118,9 @@ struct ContentView: View {
|
||||
.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."),
|
||||
message: Text("""
|
||||
There is no internet connection at the moment. Please reconnect or try again later.
|
||||
"""),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
|
@ -94,6 +94,7 @@ struct PostListFilteredView: View {
|
||||
if let postToDelete = model.postToDelete {
|
||||
model.selectedPost = nil
|
||||
DispatchQueue.main.async {
|
||||
model.editor.clearLastDraft()
|
||||
model.posts.remove(postToDelete)
|
||||
}
|
||||
model.postToDelete = nil
|
||||
@ -122,7 +123,10 @@ struct PostListFilteredView: View {
|
||||
|
||||
func delete(_ post: WFAPost) {
|
||||
DispatchQueue.main.async {
|
||||
model.selectedPost = nil
|
||||
if post == model.selectedPost {
|
||||
model.selectedPost = nil
|
||||
model.editor.clearLastDraft()
|
||||
}
|
||||
model.posts.remove(post)
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,12 @@ struct PostListView: View {
|
||||
)
|
||||
)
|
||||
.navigationSubtitle(postCount == 1 ? "\(postCount) post" : "\(postCount) posts")
|
||||
.onChange(of: selectedCollection, perform: { _ in
|
||||
DispatchQueue.main.async {
|
||||
self.model.selectedPost = nil
|
||||
self.model.editor.clearLastDraft()
|
||||
}
|
||||
})
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user