Fix lint issues.

This commit is contained in:
Brent Simmons
2025-01-22 22:18:09 -08:00
parent 40ada2ba5a
commit bbef99f2d3
92 changed files with 1651 additions and 1694 deletions

View File

@@ -27,7 +27,7 @@ class ReaderAPIAccountViewController: UITableViewController {
weak var account: Account?
var accountType: AccountType?
weak var delegate: AddAccountDismissDelegate?
override func viewDidLoad() {
super.viewDidLoad()
setupFooter()
@@ -35,7 +35,7 @@ class ReaderAPIAccountViewController: UITableViewController {
activityIndicator.isHidden = true
usernameTextField.delegate = self
passwordTextField.delegate = self
if let unwrappedAccount = account,
let credentials = try? retrieveCredentialsForAccount(for: unwrappedAccount) {
actionButton.setTitle(NSLocalizedString("Update Credentials", comment: "Update Credentials"), for: .normal)
@@ -45,7 +45,7 @@ class ReaderAPIAccountViewController: UITableViewController {
} else {
actionButton.setTitle(NSLocalizedString("Add Account", comment: "Add Account"), for: .normal)
}
if let unwrappedAccountType = accountType {
switch unwrappedAccountType {
case .freshRSS:
@@ -61,14 +61,14 @@ class ReaderAPIAccountViewController: UITableViewController {
title = ""
}
}
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: usernameTextField)
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: passwordTextField)
tableView.register(ImageHeaderView.self, forHeaderFooterViewReuseIdentifier: "SectionHeader")
}
private func setupFooter() {
switch accountType {
case .bazQux:
@@ -87,11 +87,11 @@ class ReaderAPIAccountViewController: UITableViewController {
return
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return section == 0 ? ImageHeaderView.rowHeight : super.tableView(tableView, heightForHeaderInSection: section)
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
@@ -101,7 +101,7 @@ class ReaderAPIAccountViewController: UITableViewController {
return super.tableView(tableView, viewForHeaderInSection: section)
}
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
@@ -115,8 +115,7 @@ class ReaderAPIAccountViewController: UITableViewController {
return 1
}
}
@IBAction func cancel(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
@@ -130,19 +129,19 @@ class ReaderAPIAccountViewController: UITableViewController {
showHideButton.setTitle("Show", for: .normal)
}
}
@IBAction func action(_ sender: Any) {
guard validateDataEntry(), let type = accountType else {
return
}
let username = usernameTextField.text!
let password = passwordTextField.text!
let url = apiURL()!
// When you fill in the email address via auto-complete it adds extra whitespace
let trimmedUsername = username.trimmingCharacters(in: .whitespaces)
guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: type, username: trimmedUsername) else {
showError(NSLocalizedString("There is already an account of that type with that username created.", comment: "Duplicate Error"))
return
@@ -167,15 +166,15 @@ class ReaderAPIAccountViewController: UITableViewController {
do {
self.account?.endpointURL = url
try? self.account?.removeCredentials(type: .readerBasic)
try? self.account?.removeCredentials(type: .readerAPIKey)
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
self.dismiss(animated: true, completion: nil)
self.account?.refreshAll() { result in
self.account?.refreshAll { result in
switch result {
case .success:
break
@@ -183,7 +182,7 @@ class ReaderAPIAccountViewController: UITableViewController {
self.showError(NSLocalizedString(error.localizedDescription, comment: "Account Refresh Error"))
}
}
self.delegate?.dismiss()
} catch {
self.showError(NSLocalizedString("Keychain error while storing credentials.", comment: "Credentials Error"))
@@ -197,7 +196,7 @@ class ReaderAPIAccountViewController: UITableViewController {
}
}
private func retrieveCredentialsForAccount(for account: Account) throws -> Credentials? {
switch accountType {
case .bazQux, .inoreader, .theOldReader, .freshRSS:
@@ -206,7 +205,7 @@ class ReaderAPIAccountViewController: UITableViewController {
return nil
}
}
private func headerViewImage() -> UIImage? {
if let accountType = accountType {
switch accountType {
@@ -224,7 +223,7 @@ class ReaderAPIAccountViewController: UITableViewController {
}
return nil
}
private func validateDataEntry() -> Bool {
switch accountType {
case .freshRSS:
@@ -244,7 +243,7 @@ class ReaderAPIAccountViewController: UITableViewController {
}
return true
}
@IBAction func signUpWithProvider(_ sender: Any) {
var url: URL!
switch accountType {
@@ -263,7 +262,7 @@ class ReaderAPIAccountViewController: UITableViewController {
safari.modalPresentationStyle = .currentContext
self.present(safari, animated: true, completion: nil)
}
private func apiURL() -> URL? {
switch accountType {
case .freshRSS:
@@ -278,9 +277,7 @@ class ReaderAPIAccountViewController: UITableViewController {
return nil
}
}
@objc func textDidChange(_ note: Notification) {
actionButton.isEnabled = !(usernameTextField.text?.isEmpty ?? false)
}