Remove some no-longer-needed #available checks.

This commit is contained in:
Brent Simmons
2024-02-27 20:06:57 -08:00
parent 9129cd382c
commit 22f3fb62f8
6 changed files with 37 additions and 77 deletions

View File

@@ -128,11 +128,10 @@ class AccountsNewsBlurWindowController: NSWindowController {
}
// MARK: Autofill
func enableAutofill() {
if #available(macOS 11, *) {
usernameTextField.contentType = .username
passwordTextField.contentType = .password
}
usernameTextField.contentType = .username
passwordTextField.contentType = .password
}
}

View File

@@ -196,11 +196,10 @@ class AccountsReaderAPIWindowController: NSWindowController {
}
// MARK: Autofill
func enableAutofill() {
if #available(macOS 11, *) {
usernameTextField.contentType = .username
passwordTextField.contentType = .password
}
usernameTextField.contentType = .username
passwordTextField.contentType = .password
}
}

View File

@@ -102,45 +102,24 @@ struct AddAccountsView: View {
HStack(spacing: 12) {
Spacer()
if #available(OSX 11.0, *) {
Button(action: {
parent?.dismiss(nil)
}, label: {
Text("Cancel")
.frame(width: 76)
})
.help("Cancel")
.keyboardShortcut(.cancelAction)
} else {
Button(action: {
parent?.dismiss(nil)
}, label: {
Text("Cancel")
.frame(width: 76)
})
.accessibility(label: Text("Add Account"))
}
if #available(OSX 11.0, *) {
Button(action: {
addAccountDelegate?.presentSheetForAccount(selectedAccount)
parent?.dismiss(nil)
}, label: {
Text("Continue")
.frame(width: 76)
})
.help("Add Account")
.keyboardShortcut(.defaultAction)
} else {
Button(action: {
addAccountDelegate?.presentSheetForAccount(selectedAccount)
parent?.dismiss(nil)
}, label: {
Text("Continue")
.frame(width: 76)
})
}
Button(action: {
parent?.dismiss(nil)
}, label: {
Text("Cancel")
.frame(width: 76)
})
.help("Cancel")
.keyboardShortcut(.cancelAction)
Button(action: {
addAccountDelegate?.presentSheetForAccount(selectedAccount)
parent?.dismiss(nil)
}, label: {
Text("Continue")
.frame(width: 76)
})
.help("Add Account")
.keyboardShortcut(.defaultAction)
}
.padding(.top, 12)
.padding(.bottom, 4)

View File

@@ -11,20 +11,11 @@ import AppKit
extension NSView {
func constraintsToMakeSubViewFullSize(_ subview: NSView) -> [NSLayoutConstraint] {
if #available(macOS 11, *) {
let leadingConstraint = NSLayoutConstraint(item: subview, attribute: .leading, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .leading, multiplier: 1.0, constant: 0.0)
let trailingConstraint = NSLayoutConstraint(item: subview, attribute: .trailing, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .trailing, multiplier: 1.0, constant: 0.0)
let topConstraint = NSLayoutConstraint(item: subview, attribute: .top, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .top, multiplier: 1.0, constant: 0.0)
let bottomConstraint = NSLayoutConstraint(item: subview, attribute: .bottom, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .bottom, multiplier: 1.0, constant: 0.0)
return [leadingConstraint, trailingConstraint, topConstraint, bottomConstraint]
} else {
let leadingConstraint = NSLayoutConstraint(item: subview, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0.0)
let trailingConstraint = NSLayoutConstraint(item: subview, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0.0)
let topConstraint = NSLayoutConstraint(item: subview, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0)
let bottomConstraint = NSLayoutConstraint(item: subview, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0.0)
return [leadingConstraint, trailingConstraint, topConstraint, bottomConstraint]
}
let leadingConstraint = NSLayoutConstraint(item: subview, attribute: .leading, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .leading, multiplier: 1.0, constant: 0.0)
let trailingConstraint = NSLayoutConstraint(item: subview, attribute: .trailing, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .trailing, multiplier: 1.0, constant: 0.0)
let topConstraint = NSLayoutConstraint(item: subview, attribute: .top, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .top, multiplier: 1.0, constant: 0.0)
let bottomConstraint = NSLayoutConstraint(item: subview, attribute: .bottom, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .bottom, multiplier: 1.0, constant: 0.0)
return [leadingConstraint, trailingConstraint, topConstraint, bottomConstraint]
}
}

View File

@@ -396,16 +396,14 @@ private extension AppDelegate {
}
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.log) { [unowned self] in
if !AccountManager.shared.isSuspended {
if #available(iOS 14, *) {
try? WidgetDataEncoder.shared.encodeWidgetData()
}
try? WidgetDataEncoder.shared.encodeWidgetData()
self.suspendApplication()
os_log("Account refresh operation completed.", log: self.log, type: .info)
task.setTaskCompleted(success: true)
}
}
}
// set expiration handler
task.expirationHandler = { [weak task] in
DispatchQueue.main.sync {
@@ -443,9 +441,7 @@ private extension AppDelegate {
self.prepareAccountsForBackground()
account!.syncArticleStatus(completion: { [weak self] _ in
if !AccountManager.shared.isSuspended {
if #available(iOS 14, *) {
try? WidgetDataEncoder.shared.encodeWidgetData()
}
try? WidgetDataEncoder.shared.encodeWidgetData()
self?.prepareAccountsForBackground()
self?.suspendApplication()
}
@@ -472,9 +468,7 @@ private extension AppDelegate {
account!.markArticles(article!, statusKey: .starred, flag: true) { _ in }
account!.syncArticleStatus(completion: { [weak self] _ in
if !AccountManager.shared.isSuspended {
if #available(iOS 14, *) {
try? WidgetDataEncoder.shared.encodeWidgetData()
}
try? WidgetDataEncoder.shared.encodeWidgetData()
self?.prepareAccountsForBackground()
self?.suspendApplication()
}

View File

@@ -65,9 +65,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
func sceneDidEnterBackground(_ scene: UIScene) {
if #available(iOS 14, *) {
try? WidgetDataEncoder.shared.encodeWidgetData()
}
try? WidgetDataEncoder.shared.encodeWidgetData()
ArticleStringFormatter.emptyCaches()
appDelegate.prepareAccountsForBackground()
}