Merge pull request #84 from writeas/prompt-to-login-on-publish

Open the preferences window on publish if not logged in [macOS]
This commit is contained in:
Angelo Stavrow 2020-09-30 11:20:58 -04:00 committed by GitHub
commit c08e1c2d07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,7 +115,10 @@ struct PostEditorView: View {
if model.account.isLoggedIn {
publishPost()
} else {
// TODO: Open the Preferences window.
let mainMenu = NSApplication.shared.mainMenu
let appMenuItem = mainMenu?.item(withTitle: "WriteFreely")
let prefsItem = appMenuItem?.submenu?.item(withTitle: "Preferences…")
NSApplication.shared.sendAction(prefsItem!.action!, to: prefsItem?.target, from: nil)
}
}, label: {
Image(systemName: "paperplane")