Dispatch setting of selectedPost to the main thread

This commit is contained in:
Angelo Stavrow 2020-09-23 16:40:07 -04:00
parent 70189a6193
commit 5bcd3185bf
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 5 additions and 3 deletions

View File

@ -59,7 +59,9 @@ class WriteFreelyModel: ObservableObject {
}
if let lastDraft = self.editor.fetchLastDraft() {
self.selectedPost = lastDraft
DispatchQueue.main.async {
self.selectedPost = lastDraft
}
} else {
let managedPost = WFAPost(context: LocalStorageManager.persistentContainer.viewContext)
managedPost.createdDate = Date()
@ -80,8 +82,8 @@ class WriteFreelyModel: ObservableObject {
}
DispatchQueue.main.async {
LocalStorageManager().saveContext()
self.selectedPost = managedPost
}
self.selectedPost = managedPost
}
}

View File

@ -121,8 +121,8 @@ struct PostListView: View {
}
DispatchQueue.main.async {
LocalStorageManager().saveContext()
model.selectedPost = managedPost
}
model.selectedPost = managedPost
}
}