Rename OAuthAccountAuthorizationOperation to FeedlyOAuthAccountAuthorizationOperation.

This commit is contained in:
Brent Simmons 2024-05-01 20:58:32 -07:00
parent e56f7a73b8
commit 8de7b56f61
3 changed files with 16 additions and 16 deletions

View File

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

View File

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

View File

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