Activate NetNewsWire after authorizing it with Feedly so users are not left in their browser, unable to see the result of authorizing NNW.

This commit is contained in:
Kiel Gillard 🤪 2020-09-22 09:49:59 +10:00
parent bc358c3af4
commit 67d80dbaec
1 changed files with 10 additions and 0 deletions

View File

@ -148,6 +148,12 @@ extension AccountsAddViewController: AccountsAddTableCellViewDelegate {
extension AccountsAddViewController: OAuthAccountAuthorizationOperationDelegate { extension AccountsAddViewController: OAuthAccountAuthorizationOperationDelegate {
func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) {
// `OAuthAccountAuthorizationOperation` is using `ASWebAuthenticationSession` which bounces the user
// to their browser on macOS for authorizing NetNewsWire to access the user's Feedly account.
// When this authorization is granted, the browser remains the foreground app which is unfortunate
// because the user probably wants to see the result of authorizing NetNewsWire to act on their behalf.
NSApp.activate(ignoringOtherApps: true)
account.refreshAll { [weak self] result in account.refreshAll { [weak self] result in
switch result { switch result {
case .success: case .success:
@ -159,6 +165,10 @@ extension AccountsAddViewController: OAuthAccountAuthorizationOperationDelegate
} }
func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) {
// `OAuthAccountAuthorizationOperation` is using `ASWebAuthenticationSession` which bounces the user
// to their browser on macOS for authorizing NetNewsWire to access the user's Feedly account.
NSApp.activate(ignoringOtherApps: true)
view.window?.presentError(error) view.window?.presentError(error)
} }
} }