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(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||||
Alert(
|
Alert(
|
||||||
title: Text("Connection Error"),
|
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: {
|
dismissButton: .default(Text("OK"), action: {
|
||||||
model.isPresentingNetworkErrorAlert = false
|
model.isPresentingNetworkErrorAlert = false
|
||||||
})
|
})
|
||||||
|
@ -94,6 +94,7 @@ struct PostListFilteredView: View {
|
|||||||
if let postToDelete = model.postToDelete {
|
if let postToDelete = model.postToDelete {
|
||||||
model.selectedPost = nil
|
model.selectedPost = nil
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
model.editor.clearLastDraft()
|
||||||
model.posts.remove(postToDelete)
|
model.posts.remove(postToDelete)
|
||||||
}
|
}
|
||||||
model.postToDelete = nil
|
model.postToDelete = nil
|
||||||
@ -122,7 +123,10 @@ struct PostListFilteredView: View {
|
|||||||
|
|
||||||
func delete(_ post: WFAPost) {
|
func delete(_ post: WFAPost) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
model.selectedPost = nil
|
if post == model.selectedPost {
|
||||||
|
model.selectedPost = nil
|
||||||
|
model.editor.clearLastDraft()
|
||||||
|
}
|
||||||
model.posts.remove(post)
|
model.posts.remove(post)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,12 @@ struct PostListView: View {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.navigationSubtitle(postCount == 1 ? "\(postCount) post" : "\(postCount) posts")
|
.navigationSubtitle(postCount == 1 ? "\(postCount) post" : "\(postCount) posts")
|
||||||
|
.onChange(of: selectedCollection, perform: { _ in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.model.selectedPost = nil
|
||||||
|
self.model.editor.clearLastDraft()
|
||||||
|
}
|
||||||
|
})
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user