From f589d427943a5b88314f9a2a68b39f736d0baaa5 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Wed, 27 Jan 2021 10:37:18 -0500 Subject: [PATCH] Check that we're working with model's selectedPost property --- macOS/Navigation/ActivePostToolbarView.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/macOS/Navigation/ActivePostToolbarView.swift b/macOS/Navigation/ActivePostToolbarView.swift index 7b6d0c9..f95d123 100644 --- a/macOS/Navigation/ActivePostToolbarView.swift +++ b/macOS/Navigation/ActivePostToolbarView.swift @@ -64,7 +64,7 @@ struct ActivePostToolbarView: View { }, label: { Label("Publish…", systemImage: "paperplane") }) - .disabled(model.selectedPost!.body.isEmpty) + .disabled(model.selectedPost?.body.isEmpty ?? true) .help("Publish the post to the web.\(model.account.isLoggedIn ? "" : " You must be logged in to do this.")") // swiftlint:disable:this line_length } else { HStack(spacing: 4) { @@ -114,6 +114,9 @@ struct ActivePostToolbarView: View { } private func publishPost(_ post: WFAPost) { + if post != model.selectedPost { + return + } DispatchQueue.main.async { LocalStorageManager().saveContext() model.publish(post: post)