Open the preferences window on publish if not logged in [macOS]

This commit is contained in:
Angelo Stavrow 2020-09-30 09:36:57 -04:00
parent e735e7a3d1
commit cf5f0fe4de
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

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")