From 8de7b56f61d7539e523e9d94aa22ce7ab204f21c Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 1 May 2024 20:58:32 -0700 Subject: [PATCH] Rename OAuthAccountAuthorizationOperation to FeedlyOAuthAccountAuthorizationOperation. --- ...FeedlyOAuthAccountAuthorizationOperation.swift} | 14 +++++++------- .../AccountsPreferencesViewController.swift | 10 +++++----- iOS/Settings/AddAccountViewController.swift | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) rename Account/Sources/Account/Feedly/{OAuthAccountAuthorizationOperation.swift => FeedlyOAuthAccountAuthorizationOperation.swift} (90%) diff --git a/Account/Sources/Account/Feedly/OAuthAccountAuthorizationOperation.swift b/Account/Sources/Account/Feedly/FeedlyOAuthAccountAuthorizationOperation.swift similarity index 90% rename from Account/Sources/Account/Feedly/OAuthAccountAuthorizationOperation.swift rename to Account/Sources/Account/Feedly/FeedlyOAuthAccountAuthorizationOperation.swift index bd10c7622..d818a0044 100644 --- a/Account/Sources/Account/Feedly/OAuthAccountAuthorizationOperation.swift +++ b/Account/Sources/Account/Feedly/FeedlyOAuthAccountAuthorizationOperation.swift @@ -12,20 +12,20 @@ import Secrets import Core import Feedly -public protocol OAuthAccountAuthorizationOperationDelegate: AnyObject { +public protocol FeedlyOAuthAccountAuthorizationOperationDelegate: AnyObject { - @MainActor func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) - @MainActor func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) + @MainActor func oauthAccountAuthorizationOperation(_ operation: FeedlyOAuthAccountAuthorizationOperation, didCreate account: Account) + @MainActor func oauthAccountAuthorizationOperation(_ operation: FeedlyOAuthAccountAuthorizationOperation, didFailWith error: Error) } -public enum OAuthAccountAuthorizationOperationError: LocalizedError { +public enum FeedlyOAuthAccountAuthorizationOperationError: LocalizedError { case duplicateAccount public var errorDescription: String? { return NSLocalizedString("There is already a Feedly account with that username created.", comment: "Duplicate Error") } } -@MainActor @objc public final class OAuthAccountAuthorizationOperation: NSObject, MainThreadOperation, ASWebAuthenticationPresentationContextProviding { +@MainActor @objc public final class FeedlyOAuthAccountAuthorizationOperation: NSObject, MainThreadOperation, ASWebAuthenticationPresentationContextProviding { public var isCanceled: Bool = false { didSet { @@ -40,7 +40,7 @@ public enum OAuthAccountAuthorizationOperationError: LocalizedError { public var completionBlock: MainThreadOperation.MainThreadOperationCompletionBlock? public weak var presentationAnchor: ASPresentationAnchor? - public weak var delegate: OAuthAccountAuthorizationOperationDelegate? + public weak var delegate: FeedlyOAuthAccountAuthorizationOperationDelegate? private let accountType: AccountType private let oauthClient: OAuthAuthorizationClient @@ -145,7 +145,7 @@ public enum OAuthAccountAuthorizationOperationError: LocalizedError { @MainActor private func saveAccount(for grant: OAuthAuthorizationGrant) { guard !AccountManager.shared.duplicateServiceAccount(type: .feedly, username: grant.accessToken.username) else { - didFinish(OAuthAccountAuthorizationOperationError.duplicateAccount) + didFinish(FeedlyOAuthAccountAuthorizationOperationError.duplicateAccount) return } diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index 244cce6e6..d2b449b2f 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -175,7 +175,7 @@ extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelega accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) addAccountWindowController = accountsReaderAPIWindowController case .feedly: - let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly, secretsProvider: Secrets()) + let addAccount = FeedlyOAuthAccountAuthorizationOperation(accountType: .feedly, secretsProvider: Secrets()) addAccount.delegate = self addAccount.presentationAnchor = self.view.window! runAwaitingFeedlyLoginAlertModal(forLifetimeOf: addAccount) @@ -187,7 +187,7 @@ extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelega } } - private func runAwaitingFeedlyLoginAlertModal(forLifetimeOf operation: OAuthAccountAuthorizationOperation) { + private func runAwaitingFeedlyLoginAlertModal(forLifetimeOf operation: FeedlyOAuthAccountAuthorizationOperation) { let alert = NSAlert() alert.alertStyle = .informational alert.messageText = NSLocalizedString("Waiting for access to Feedly", @@ -262,9 +262,9 @@ private extension AccountsPreferencesViewController { } -extension AccountsPreferencesViewController: OAuthAccountAuthorizationOperationDelegate { +extension AccountsPreferencesViewController: FeedlyOAuthAccountAuthorizationOperationDelegate { - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { + func oauthAccountAuthorizationOperation(_ operation: FeedlyOAuthAccountAuthorizationOperation, 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 @@ -280,7 +280,7 @@ extension AccountsPreferencesViewController: OAuthAccountAuthorizationOperationD } } - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { + func oauthAccountAuthorizationOperation(_ operation: FeedlyOAuthAccountAuthorizationOperation, 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) diff --git a/iOS/Settings/AddAccountViewController.swift b/iOS/Settings/AddAccountViewController.swift index 4780dace6..792feb708 100644 --- a/iOS/Settings/AddAccountViewController.swift +++ b/iOS/Settings/AddAccountViewController.swift @@ -197,7 +197,7 @@ class AddAccountViewController: UITableViewController, AddAccountDismissDelegate addViewController.delegate = self present(navController, animated: true) case .feedly: - let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly, secretsProvider: Secrets()) + let addAccount = FeedlyOAuthAccountAuthorizationOperation(accountType: .feedly, secretsProvider: Secrets()) addAccount.delegate = self addAccount.presentationAnchor = self.view.window! MainThreadOperationQueue.shared.add(addAccount) @@ -223,9 +223,9 @@ class AddAccountViewController: UITableViewController, AddAccountDismissDelegate } -extension AddAccountViewController: OAuthAccountAuthorizationOperationDelegate { +extension AddAccountViewController: FeedlyOAuthAccountAuthorizationOperationDelegate { - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { + func oauthAccountAuthorizationOperation(_ operation: FeedlyOAuthAccountAuthorizationOperation, didCreate account: Account) { let rootViewController = view.window?.rootViewController @@ -240,7 +240,7 @@ extension AddAccountViewController: OAuthAccountAuthorizationOperationDelegate { dismiss() } - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { + func oauthAccountAuthorizationOperation(_ operation: FeedlyOAuthAccountAuthorizationOperation, didFailWith error: Error) { presentError(error) } }