mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Save managed object context before publishing a local post
This commit is contained in:
parent
614d5fa72c
commit
a20b2911b7
@ -30,8 +30,7 @@ struct PostEditorView: View {
|
||||
}
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(action: {
|
||||
model.publish(post: post)
|
||||
post.status = PostStatus.published.rawValue
|
||||
publishPost()
|
||||
}, label: {
|
||||
Image(systemName: "paperplane")
|
||||
})
|
||||
@ -50,6 +49,14 @@ struct PostEditorView: View {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private func publishPost() {
|
||||
DispatchQueue.main.async {
|
||||
LocalStorageManager().saveContext()
|
||||
model.posts.loadCachedPosts()
|
||||
model.publish(post: post)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PostEditorView_Previews: PreviewProvider {
|
||||
|
@ -7,12 +7,12 @@
|
||||
<key>WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
Loading…
Reference in New Issue
Block a user