From 056aadec140b30036eaf8b18716d648c8ef52327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiel=20Gillard=20=F0=9F=A4=AA?= Date: Tue, 22 Sep 2020 10:14:14 +1000 Subject: [PATCH] Multiplatform: activate the app so users can see the results of their actions. --- .../Add Account/AddAccountModel.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountModel.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountModel.swift index 6354600ba..21074d617 100644 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountModel.swift +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountModel.swift @@ -277,8 +277,14 @@ extension AddAccountModel { // MARK:- OAuthAccountAuthorizationOperationDelegate extension AddAccountModel: OAuthAccountAuthorizationOperationDelegate { func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { + accountIsAuthenticating = false accountAdded = true + + // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. + // Ensure the app is in the foreground so the user can see their Feedly account load. + NSApplication.shared.activate(ignoringOtherApps: true) + account.refreshAll { [weak self] result in switch result { case .success: @@ -291,6 +297,11 @@ extension AddAccountModel: OAuthAccountAuthorizationOperationDelegate { func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { accountIsAuthenticating = false + + // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. + // Ensure the app is in the foreground so the user can see the error. + NSApplication.shared.activate(ignoringOtherApps: true) + addAccountError = .other(error: error) } }