Removes dead code

This commit is contained in:
Stuart Breckenridge 2020-10-30 06:16:28 +08:00
parent 80744982f5
commit bd3fd1ef2a
2 changed files with 31 additions and 24 deletions

View File

@ -34,7 +34,6 @@ final class AccountsPreferencesViewController: NSViewController {
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil)
//showController(AccountsAddViewController())
// Fix tableView frame  for some reason IB wants it 1pt wider than the clip view. This leads to unwanted horizontal scrolling. // Fix tableView frame  for some reason IB wants it 1pt wider than the clip view. This leads to unwanted horizontal scrolling.
var rTable = tableView.frame var rTable = tableView.frame
@ -43,7 +42,6 @@ final class AccountsPreferencesViewController: NSViewController {
} }
@IBAction func addAccount(_ sender: Any) { @IBAction func addAccount(_ sender: Any) {
//tableView.selectRowIndexes([], byExtendingSelection: false)
let controller = NSHostingController(rootView: AddAccountsView(delegate: self)) let controller = NSHostingController(rootView: AddAccountsView(delegate: self))
controller.rootView.parent = controller controller.rootView.parent = controller
presentAsSheet(controller) presentAsSheet(controller)
@ -70,7 +68,6 @@ final class AccountsPreferencesViewController: NSViewController {
if result == NSApplication.ModalResponse.alertFirstButtonReturn { if result == NSApplication.ModalResponse.alertFirstButtonReturn {
guard let self = self else { return } guard let self = self else { return }
AccountManager.shared.deleteAccount(self.sortedAccounts[self.tableView.selectedRow]) AccountManager.shared.deleteAccount(self.sortedAccounts[self.tableView.selectedRow])
//self.showController(AccountsAddViewController())
} }
} }
@ -151,64 +148,46 @@ extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelega
case .onMyMac: case .onMyMac:
let accountsAddLocalWindowController = AccountsAddLocalWindowController() let accountsAddLocalWindowController = AccountsAddLocalWindowController()
accountsAddLocalWindowController.runSheetOnWindow(self.view.window!) accountsAddLocalWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsAddLocalWindowController
case .cloudKit: case .cloudKit:
let accountsAddCloudKitWindowController = AccountsAddCloudKitWindowController() let accountsAddCloudKitWindowController = AccountsAddCloudKitWindowController()
accountsAddCloudKitWindowController.runSheetOnWindow(self.view.window!) { response in accountsAddCloudKitWindowController.runSheetOnWindow(self.view.window!) { response in
if response == NSApplication.ModalResponse.OK { if response == NSApplication.ModalResponse.OK {
//self.restrictAccounts() self.tableView.reloadData()
//self.tableView.reloadData()
} }
} }
//accountsAddWindowController = accountsAddCloudKitWindowController
case .feedbin: case .feedbin:
let accountsFeedbinWindowController = AccountsFeedbinWindowController() let accountsFeedbinWindowController = AccountsFeedbinWindowController()
accountsFeedbinWindowController.runSheetOnWindow(self.view.window!) accountsFeedbinWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsFeedbinWindowController
case .feedWrangler: case .feedWrangler:
let accountsFeedWranglerWindowController = AccountsFeedWranglerWindowController() let accountsFeedWranglerWindowController = AccountsFeedWranglerWindowController()
accountsFeedWranglerWindowController.runSheetOnWindow(self.view.window!) accountsFeedWranglerWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsFeedWranglerWindowController
case .freshRSS: case .freshRSS:
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
accountsReaderAPIWindowController.accountType = .freshRSS accountsReaderAPIWindowController.accountType = .freshRSS
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsReaderAPIWindowController
case .feedly: case .feedly:
let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly) let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly)
//addAccount.delegate = self addAccount.delegate = self
addAccount.presentationAnchor = self.view.window! addAccount.presentationAnchor = self.view.window!
runAwaitingFeedlyLoginAlertModal(forLifetimeOf: addAccount) runAwaitingFeedlyLoginAlertModal(forLifetimeOf: addAccount)
MainThreadOperationQueue.shared.add(addAccount) MainThreadOperationQueue.shared.add(addAccount)
case .newsBlur: case .newsBlur:
let accountsNewsBlurWindowController = AccountsNewsBlurWindowController() let accountsNewsBlurWindowController = AccountsNewsBlurWindowController()
accountsNewsBlurWindowController.runSheetOnWindow(self.view.window!) accountsNewsBlurWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsNewsBlurWindowController
case .inoreader: case .inoreader:
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
accountsReaderAPIWindowController.accountType = .inoreader accountsReaderAPIWindowController.accountType = .inoreader
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsReaderAPIWindowController
case .bazQux: case .bazQux:
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
accountsReaderAPIWindowController.accountType = .bazQux accountsReaderAPIWindowController.accountType = .bazQux
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsReaderAPIWindowController
case .theOldReader: case .theOldReader:
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
accountsReaderAPIWindowController.accountType = .theOldReader accountsReaderAPIWindowController.accountType = .theOldReader
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
//accountsAddWindowController = accountsReaderAPIWindowController
} }
} }
@ -264,3 +243,30 @@ private extension AccountsPreferencesViewController {
} }
extension AccountsPreferencesViewController: OAuthAccountAuthorizationOperationDelegate {
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
switch result {
case .success:
break
case .failure(let error):
self?.presentError(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 File

@ -59,10 +59,11 @@ struct AddAccountsView: View {
weak var parent: NSHostingController<AddAccountsView>? // required because presentationMode.dismiss() doesn't work weak var parent: NSHostingController<AddAccountsView>? // required because presentationMode.dismiss() doesn't work
var addAccountDelegate: AccountsPreferencesAddAccountDelegate? var addAccountDelegate: AccountsPreferencesAddAccountDelegate?
@State private var selectedAccount: AccountType = .onMyMac
init(delegate: AccountsPreferencesAddAccountDelegate?) { init(delegate: AccountsPreferencesAddAccountDelegate?) {
self.addAccountDelegate = delegate self.addAccountDelegate = delegate
} }
@State private var selectedAccount: AccountType = .onMyMac
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: 8) {