Implement basic publishing

This commit is contained in:
Angelo Stavrow 2020-11-25 16:06:52 -05:00
parent acde0c8978
commit 7398c1d3cf
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -70,8 +70,13 @@ struct ContentView: View {
}
ToolbarItemGroup(placement: .primaryAction) {
if let selectedPost = model.selectedPost {
Button(action: {}, label: { Image(systemName: "paperplane") })
.disabled(selectedPost.body.isEmpty)
Button(action: {
DispatchQueue.main.async {
LocalStorageManager().saveContext()
model.publish(post: selectedPost)
}
}, label: { Image(systemName: "paperplane") })
.disabled(selectedPost.body.isEmpty || selectedPost.status == PostStatus.published.rawValue)
Button(action: {}, label: { Image(systemName: "square.and.arrow.up") })
.disabled(selectedPost.status == PostStatus.local.rawValue)
}