diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index 5ed54b7..d8c908b 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -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 }) diff --git a/Shared/PostList/PostListFilteredView.swift b/Shared/PostList/PostListFilteredView.swift index 04f9eaa..7df2c7c 100644 --- a/Shared/PostList/PostListFilteredView.swift +++ b/Shared/PostList/PostListFilteredView.swift @@ -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) } } diff --git a/Shared/PostList/PostListView.swift b/Shared/PostList/PostListView.swift index ffc545b..2fb4b7a 100644 --- a/Shared/PostList/PostListView.swift +++ b/Shared/PostList/PostListView.swift @@ -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 } }