mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Dispatch setting of selectedPost to the main thread
This commit is contained in:
parent
70189a6193
commit
5bcd3185bf
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,8 @@ struct PostListView: View {
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
LocalStorageManager().saveContext()
|
||||
model.selectedPost = managedPost
|
||||
}
|
||||
model.selectedPost = managedPost
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user