From 851a0b6465be46bb69912649dc9ef16f3edc314e Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Tue, 15 Dec 2020 15:10:26 -0500 Subject: [PATCH] Open app prefs window if not logged in on publish --- macOS/Navigation/ActivePostToolbarView.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/macOS/Navigation/ActivePostToolbarView.swift b/macOS/Navigation/ActivePostToolbarView.swift index ef1ca42..3674d5b 100644 --- a/macOS/Navigation/ActivePostToolbarView.swift +++ b/macOS/Navigation/ActivePostToolbarView.swift @@ -42,7 +42,7 @@ struct ActivePostToolbarView: View { publishPost(activePost) } } else { - // present login screen + openSettingsWindow() } }, label: { Text("\(model.account.server == "https://write.as" ? "Anonymous" : "Drafts")") @@ -55,7 +55,7 @@ struct ActivePostToolbarView: View { publishPost(activePost) } } else { - // present login screen + openSettingsWindow() } }, label: { Text("\(collection.title)") @@ -95,4 +95,9 @@ struct ActivePostToolbarView: View { model.publish(post: post) } } + + private func openSettingsWindow() { + guard let menuItem = NSApplication.shared.mainMenu?.item(at: 0)?.submenu?.item(at: 2) else { return } + NSApplication.shared.sendAction(menuItem.action!, to: menuItem.target, from: nil) + } }