Fix crashing bug on iPad and macOS when removing blank posts

This commit is contained in:
Angelo Stavrow 2020-09-29 12:39:19 -04:00
parent bc4c43f40c
commit 776f1ed3ed
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
3 changed files with 8 additions and 5 deletions

View File

@ -35,7 +35,9 @@ struct PostEditorStatusToolbarView: View {
.foregroundColor(.secondary)
Button(action: {
model.selectedPost = nil
model.posts.remove(post)
DispatchQueue.main.async {
model.posts.remove(post)
}
}, label: {
Image(systemName: "trash")
})

View File

@ -30,8 +30,9 @@ struct PostEditorView: View {
.foregroundColor(.secondary)
Button(action: {
self.presentationMode.wrappedValue.dismiss()
model.selectedPost = nil
model.posts.remove(post)
DispatchQueue.main.async {
model.posts.remove(post)
}
}, label: {
Image(systemName: "trash")
})
@ -163,7 +164,7 @@ struct PostEditorView: View {
&& post.status == PostStatus.local.rawValue
&& post.updatedDate == nil
&& post.postId == nil {
withAnimation {
DispatchQueue.main.async {
model.posts.remove(post)
model.posts.loadCachedPosts()
}

View File

@ -145,7 +145,7 @@ struct PostEditorView: View {
&& post.status == PostStatus.local.rawValue
&& post.updatedDate == nil
&& post.postId == nil {
withAnimation {
DispatchQueue.main.async {
model.posts.remove(post)
model.posts.loadCachedPosts()
}