Open app prefs window if not logged in on publish

This commit is contained in:
Angelo Stavrow 2020-12-15 15:10:26 -05:00
parent f52fae335b
commit 851a0b6465
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -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)
}
}