Save managed object context before publishing a local post

This commit is contained in:
Angelo Stavrow 2020-09-10 12:29:24 -04:00
parent 614d5fa72c
commit a20b2911b7
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 11 additions and 4 deletions

View File

@ -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 {

View File

@ -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>