Fix various SwiftLint warnings.

This commit is contained in:
Brent Simmons committed 2026-01-01 17:55:12 -08:00
1 parent 50140acac2
commit 0832a7cf67
52 files changed
+165 -282

No files matched your search

-1
View File
@@ -32,7 +32,6 @@ import RSWeb
open(urlString, inBackground: invert ? !AppDefaults.shared.openInBrowserInBackground : AppDefaults.shared.openInBrowserInBackground)
}
/// Opens a URL in the default browser.
///
/// - Parameters:
@@ -13,7 +13,6 @@ import Articles
import Account
final class FeedInspectorViewController: NSViewController, Inspector {
@IBOutlet var iconView: IconView!
@IBOutlet var nameTextField: NSTextField?
@IBOutlet var homePageURLTextField: NSTextField?
@@ -114,7 +113,6 @@ final class FeedInspectorViewController: NSViewController, Inspector {
@objc func imageDidBecomeAvailable(_ note: Notification) {
updateImage()
}
}
extension FeedInspectorViewController: NSTextFieldDelegate {
@@ -122,7 +120,6 @@ extension FeedInspectorViewController: NSTextFieldDelegate {
func controlTextDidEndEditing(_ note: Notification) {
renameFeedIfNecessary()
}
}
private extension FeedInspectorViewController {
@@ -135,7 +132,6 @@ private extension FeedInspectorViewController {
feed = singleFeed
}
@objc func updateUI() {
updateImage()
updateName()
@@ -9,7 +9,6 @@
import AppKit
@MainActor protocol Inspector: AnyObject {
var objects: [Any]? { get set }
var isFallbackInspector: Bool { get } // Can handle nothing-to-inspect or unexpected type of objects.
var windowTitle: String { get }
@@ -19,10 +18,8 @@ import AppKit
typealias InspectorViewController = Inspector & NSViewController
final class InspectorWindowController: NSWindowController {
class var shouldOpenAtStartup: Bool {
static var shouldOpenAtStartup: Bool {
return UserDefaults.standard.bool(forKey: DefaultsKey.windowIsOpen)
}
@@ -75,7 +72,7 @@ final class InspectorWindowController: NSWindowController {
func inspector(for objects: [Any]?) -> InspectorViewController {
var fallbackInspector: InspectorViewController? = nil
var fallbackInspector: InspectorViewController?
for inspector in inspectors {
if inspector.isFallbackInspector {
@@ -74,5 +74,3 @@ private extension DetailStatusBarView {
}
}
}
+2 -2
View File
@@ -63,7 +63,7 @@ struct PasteboardFeed: Hashable {
let feedID = dictionary[Key.feedID]
let editedName = dictionary[Key.editedName]
var accountType: AccountType? = nil
var accountType: AccountType?
if let accountTypeString = dictionary[Key.accountType], let accountTypeInt = Int(accountTypeString) {
accountType = AccountType(rawValue: accountTypeInt)
}
@@ -168,7 +168,7 @@ extension Feed: @retroactive PasteboardWriterOwner {
static let feedUTIInternal = "com.ranchero.NetNewsWire-Evergreen.internal.feed"
static let feedUTIInternalType = NSPasteboard.PasteboardType(rawValue: feedUTIInternal)
var containerID: ContainerIdentifier? = nil
var containerID: ContainerIdentifier?
init(feed: Feed) {
self.feed = feed
@@ -13,7 +13,6 @@ import RSCore
typealias PasteboardFolderDictionary = [String: String]
@MainActor struct PasteboardFolder: Hashable {
private struct Key {
static let name = "name"
// Internal
@@ -21,7 +20,6 @@ typealias PasteboardFolderDictionary = [String: String]
static let accountID = "accountID"
}
let name: String
let folderID: String?
let accountID: String?
@@ -392,7 +392,6 @@ extension Notification.Name {
menu.takeItems(from: contextualMenu)
}
// MARK: - NSOutlineViewDelegate
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
@@ -602,7 +601,6 @@ private extension SidebarViewController {
treeControllerDelegate.addFilterException(folderSidebarItemID)
}
func queueRebuildTreeAndRestoreSelection() {
rebuildTreeAndRestoreSelectionQueue.add(self, #selector(rebuildTreeAndRestoreSelection))
}
@@ -114,7 +114,6 @@ extension TimelineViewController {
}
}
private extension TimelineViewController {
func markArticles(_ articles: [Article], read: Bool) {
@@ -286,7 +285,6 @@ private extension TimelineViewController {
return menuItem(NSLocalizedString("Copy External URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), urlString, image: Assets.Images.copy)
}
func menuItem(_ title: String, _ action: Selector, _ representedObject: Any, image: RSImage?) -> NSMenuItem {
let item = NSMenuItem(title: title, action: action, keyEquivalent: "")
@@ -300,7 +298,6 @@ private extension TimelineViewController {
}
private final class SharingCommandInfo {
let service: NSSharingService
let items: [Any]
@@ -387,7 +387,6 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
}
}
// MARK: - Actions
@objc func openArticleInBrowser(_ sender: Any?) {
@@ -560,7 +559,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
func markOlderArticlesRead(_ selectedArticles: [Article]) {
// Mark articles older than the selectedArticles(s) as read.
var cutoffDate: Date? = nil
var cutoffDate: Date?
for article in selectedArticles {
if cutoffDate == nil {
cutoffDate = article.logicalDatePublished
@@ -40,7 +40,6 @@ final class AccountsPreferencesViewController: NSViewController {
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil)
// 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
rTable.size.width = tableView.superview!.frame.size.width
@@ -174,7 +174,6 @@ final class AccountsReaderAPIWindowController: NSWindowController {
errorMessageLabel.stringValue = NSLocalizedString("Keychain error while storing credentials.", comment: "Credentials Error")
}
} catch {
stopAnimation()
errorMessageLabel.stringValue = NSLocalizedString("Network error. Try again later.", comment: "Credentials Error")
@@ -68,10 +68,6 @@ enum AddAccountSections: Int, CaseIterable {
AddAccountSections.selfhosted.sectionContent
}
}
}
struct AddAccountsView: View {
@@ -264,10 +260,8 @@ struct AddAccountsView: View {
}
}
struct AddAccountsView_Previews: PreviewProvider {
static var previews: some View {
AddAccountsView(delegate: nil)
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ import RSCore
}
} else if let scriptableFeed = element as? ScriptableFeed {
BatchUpdate.shared.perform {
var container: Container? = nil
var container: Container?
if let scriptableFolder = scriptableFeed.container as? ScriptableFolder {
container = scriptableFolder.folder
} else {
@@ -77,7 +77,6 @@ extension AppDelegate: AppDelegateAppleEvents {
}
// Special case URL with specific scheme handler x-netnewswire-feed: intended to ensure we open
// it regardless of which news reader may be set as the default
let nnwScheme = "x-netnewswire-feed:"
+131 -131
View File
@@ -13,120 +13,120 @@ import Articles
@objc(ScriptableFeed)
@MainActor final class ScriptableFeed: NSObject, UniqueIDScriptingObject, @preconcurrency ScriptingObjectContainer {
let feed: Feed
nonisolated(unsafe) let container: ScriptingObjectContainer
let feed: Feed
nonisolated(unsafe) let container: ScriptingObjectContainer
init (_ feed: Feed, container: ScriptingObjectContainer) {
self.feed = feed
self.container = container
}
init (_ feed: Feed, container: ScriptingObjectContainer) {
self.feed = feed
self.container = container
}
@objc(objectSpecifier)
nonisolated override var objectSpecifier: NSScriptObjectSpecifier? {
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject:self)
return scriptObjectSpecifier
}
@objc(objectSpecifier)
nonisolated override var objectSpecifier: NSScriptObjectSpecifier? {
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject: self)
return scriptObjectSpecifier
}
@objc(scriptingSpecifierDescriptor)
func scriptingSpecifierDescriptor() -> NSScriptObjectSpecifier {
objectSpecifier ?? NSScriptObjectSpecifier()
}
@objc(scriptingSpecifierDescriptor)
func scriptingSpecifierDescriptor() -> NSScriptObjectSpecifier {
objectSpecifier ?? NSScriptObjectSpecifier()
}
// MARK: --- ScriptingObject protocol ---
// MARK: - ScriptingObject protocol
nonisolated var scriptingKey: String {
"feeds"
}
nonisolated var scriptingKey: String {
"feeds"
}
// MARK: --- UniqueIdScriptingObject protocol ---
// MARK: - UniqueIdScriptingObject protocol
// I am not sure if account should prefer to be specified by name or by ID
// but in either case it seems like the accountID would be used as the keydata, so I chose ID
@objc(uniqueId)
nonisolated var scriptingUniqueID: Any {
feed.feedID
}
// I am not sure if account should prefer to be specified by name or by ID
// but in either case it seems like the accountID would be used as the keydata, so I chose ID
@objc(uniqueId)
nonisolated var scriptingUniqueID: Any {
feed.feedID
}
// MARK: --- ScriptingObjectContainer protocol ---
// MARK: - ScriptingObjectContainer protocol
nonisolated var scriptingClassDescription: NSScriptClassDescription {
classDescription as! NSScriptClassDescription
}
nonisolated var scriptingClassDescription: NSScriptClassDescription {
classDescription as! NSScriptClassDescription
}
func deleteElement(_ element:ScriptingObject) {
}
func deleteElement(_ element: ScriptingObject) {
}
// MARK: --- handle NSCreateCommand ---
// MARK: - Handle NSCreateCommand
class func urlForNewFeed(arguments: [String:Any]) -> String? {
var url: String?
if let withDataParam = arguments["ObjectData"] {
if let objectDataDescriptor = withDataParam as? NSAppleEventDescriptor {
url = objectDataDescriptor.stringValue
}
} else if let withPropsParam = arguments["ObjectProperties"] as? [String:Any] {
url = withPropsParam["url"] as? String
}
return url
}
static func urlForNewFeed(arguments: [String: Any]) -> String? {
var url: String?
if let withDataParam = arguments["ObjectData"] {
if let objectDataDescriptor = withDataParam as? NSAppleEventDescriptor {
url = objectDataDescriptor.stringValue
}
} else if let withPropsParam = arguments["ObjectProperties"] as? [String: Any] {
url = withPropsParam["url"] as? String
}
return url
}
class func scriptableFeed(_ feed: Feed, account: Account, folder: Folder?) -> ScriptableFeed {
let scriptableAccount = ScriptableAccount(account)
if let folder = folder {
let scriptableFolder = ScriptableFolder(folder, container: scriptableAccount)
return ScriptableFeed(feed, container: scriptableFolder)
} else {
return ScriptableFeed(feed, container: scriptableAccount)
}
}
static func scriptableFeed(_ feed: Feed, account: Account, folder: Folder?) -> ScriptableFeed {
let scriptableAccount = ScriptableAccount(account)
if let folder = folder {
let scriptableFolder = ScriptableFolder(folder, container: scriptableAccount)
return ScriptableFeed(feed, container: scriptableFolder)
} else {
return ScriptableFeed(feed, container: scriptableAccount)
}
}
class func scriptableFeed(for feed: Feed) -> ScriptableFeed? {
static func scriptableFeed(for feed: Feed) -> ScriptableFeed? {
guard let account = feed.account else {
return nil
}
// Find the proper container hierarchy
let containers = account.existingContainers(withFeed: feed)
var folder: Folder?
// Find the proper container hierarchy
let containers = account.existingContainers(withFeed: feed)
var folder: Folder?
// Check if feed is in a folder
for container in containers {
if let foundFolder = container as? Folder {
folder = foundFolder
break
}
}
// Check if feed is in a folder
for container in containers {
if let foundFolder = container as? Folder {
folder = foundFolder
break
}
}
return scriptableFeed(feed, account: account, folder: folder)
}
return scriptableFeed(feed, account: account, folder: folder)
}
static func handleCreateElement(command: NSCreateCommand) -> Any? {
guard command.isCreateCommand(forClass:"Feed") else {
static func handleCreateElement(command: NSCreateCommand) -> Any? {
guard command.isCreateCommand(forClass: "Feed") else {
return nil
}
guard let arguments = command.arguments else {
return nil
}
let titleFromArgs = command.property(forKey: "name") as? String
let (account, folder) = command.accountAndFolderForNewChild()
guard let url = self.urlForNewFeed(arguments:arguments) else {
let titleFromArgs = command.property(forKey: "name") as? String
let (account, folder) = command.accountAndFolderForNewChild()
guard let url = self.urlForNewFeed(arguments: arguments) else {
return nil
}
if let existingFeed = account.existingFeed(withURL: url) {
return scriptableFeed(existingFeed, account:account, folder:folder).objectSpecifier
}
if let existingFeed = account.existingFeed(withURL: url) {
return scriptableFeed(existingFeed, account: account, folder: folder).objectSpecifier
}
let container: Container = folder != nil ? folder! : account
// We need to download the feed and parse it.
// RSParser does the callback for the download on the main thread.
// Because we can't wait here (on the main thread) for the callback, we have to return from this function.
// Generally, returning from an AppleEvent handler function means that handling the Apple event is over,
// but we don’t yet have the result of the event yet, so we prevent the Apple event from returning by calling
// suspendExecution(). When we get the callback, we supply the event result and call resumeExecution().
command.suspendExecution()
// We need to download the feed and parse it.
// RSParser does the callback for the download on the main thread.
// Because we can't wait here (on the main thread) for the callback, we have to return from this function.
// Generally, returning from an AppleEvent handler function means that handling the Apple event is over,
// but we don’t yet have the result of the event yet, so we prevent the Apple event from returning by calling
// suspendExecution(). When we get the callback, we supply the event result and call resumeExecution().
command.suspendExecution()
account.createFeed(url: url, name: titleFromArgs, container: container, validateFeed: true) { result in
switch result {
@@ -140,73 +140,73 @@ import Articles
}
return nil
}
return nil
}
// MARK: --- Scriptable properties ---
// MARK: - Scriptable properties
@objc(url)
var url: String {
feed.url
}
@objc(url)
var url: String {
feed.url
}
@objc(name)
var name: String {
feed.name ?? ""
}
@objc(name)
var name: String {
feed.name ?? ""
}
@objc(homePageURL)
var homePageURL: String {
@objc(homePageURL)
var homePageURL: String {
feed.homePageURL ?? ""
}
}
@objc(iconURL)
var iconURL: String {
feed.iconURL ?? ""
}
@objc(iconURL)
var iconURL: String {
feed.iconURL ?? ""
}
@objc(faviconURL)
var faviconURL: String {
feed.faviconURL ?? ""
}
@objc(faviconURL)
var faviconURL: String {
feed.faviconURL ?? ""
}
@objc(opmlRepresentation)
var opmlRepresentation: String {
feed.OPMLString(indentLevel:0)
}
@objc(opmlRepresentation)
var opmlRepresentation: String {
feed.OPMLString(indentLevel: 0)
}
// MARK: --- scriptable elements ---
// MARK: - Scriptable elements
@objc(authors)
var authors: NSArray {
let feedAuthors = feed.authors ?? []
return feedAuthors.map { ScriptableAuthor($0, container:self) } as NSArray
}
@objc(authors)
var authors: NSArray {
let feedAuthors = feed.authors ?? []
return feedAuthors.map { ScriptableAuthor($0, container: self) } as NSArray
}
@objc(valueInAuthorsWithUniqueID:)
func valueInAuthors(withUniqueID id: String) -> ScriptableAuthor? {
@objc(valueInAuthorsWithUniqueID:)
func valueInAuthors(withUniqueID id: String) -> ScriptableAuthor? {
guard let author = feed.authors?.first(where: {$0.authorID == id}) else {
return nil
}
return ScriptableAuthor(author, container:self)
}
return ScriptableAuthor(author, container: self)
}
@objc(articles)
var articles: NSArray {
let feedArticles = (try? feed.fetchArticles()) ?? Set<Article>()
// the articles are a set, use the sorting algorithm from the viewer
let sortedArticles = feedArticles.sorted(by: {
return $0.logicalDatePublished > $1.logicalDatePublished
})
return sortedArticles.map { ScriptableArticle($0, container:self) } as NSArray
}
@objc(articles)
var articles: NSArray {
let feedArticles = (try? feed.fetchArticles()) ?? Set<Article>()
// the articles are a set, use the sorting algorithm from the viewer
let sortedArticles = feedArticles.sorted(by: {
return $0.logicalDatePublished > $1.logicalDatePublished
})
return sortedArticles.map { ScriptableArticle($0, container: self) } as NSArray
}
@objc(valueInArticlesWithUniqueID:)
func valueInArticles(withUniqueID id: String) -> ScriptableArticle? {
let articles = (try? feed.fetchArticles()) ?? Set<Article>()
@objc(valueInArticlesWithUniqueID:)
func valueInArticles(withUniqueID id: String) -> ScriptableArticle? {
let articles = (try? feed.fetchArticles()) ?? Set<Article>()
guard let article = articles.first(where: {$0.uniqueID == id}) else {
return nil
}
return ScriptableArticle(article, container: self)
}
return ScriptableArticle(article, container: self)
}
}
@@ -11,9 +11,8 @@ import Account
import Articles
extension NSApplication : @preconcurrency ScriptingObjectContainer {
// MARK: --- ScriptingObjectContainer protocol ---
// MARK: - ScriptingObjectContainer protocol
nonisolated var scriptingClassDescription: NSScriptClassDescription {
return self.classDescription as! NSScriptClassDescription
}
@@ -137,5 +136,3 @@ extension NSApplication : @preconcurrency ScriptingObjectContainer {
return ScriptableFeed(feed, container:self)
}
}
@@ -29,7 +29,7 @@ import Account
func accountAndFolderForNewChild() -> (Account, Folder?) {
let appleEvent = self.appleEvent
var account = AccountManager.shared.defaultAccount
var folder:Folder? = nil
var folder:Folder?
if let appleEvent = appleEvent {
var descriptorToConsider:NSAppleEventDescriptor?
if let insertionLocationDescriptor = appleEvent.paramDescriptor(forKeyword:keyAEInsertHere) {
@@ -25,7 +25,7 @@ import os
downloadSession.downloadProgress
}
private var completion: (() -> Void)? = nil
private var completion: (() -> Void)?
private var isSuspended = false
private lazy var downloadSession: DownloadSession = {
@@ -195,7 +195,6 @@ import os
}
}
// MARK: - Private
private extension LocalAccountRefresher {
@@ -111,7 +111,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
func fetchArticlesMatching(_ searchString: String) throws -> Set<Article> {
nonisolated(unsafe) var articles: Set<Article> = Set<Article>()
nonisolated(unsafe) var error: DatabaseError? = nil
nonisolated(unsafe) var error: DatabaseError?
queue.runInDatabaseSync { (databaseResult) in
switch databaseResult {
@@ -181,7 +181,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
let authorsNames = row.string(forColumn: DatabaseKey.authors)
let searchRowIDObject = row.object(forColumnName: DatabaseKey.searchRowID)
var searchRowID: Int? = nil
var searchRowID: Int?
if searchRowIDObject != nil && !(searchRowIDObject is NSNull) {
searchRowID = Int(row.longLongInt(forColumn: DatabaseKey.searchRowID))
}
@@ -401,7 +401,6 @@ final class ArticlesTable: DatabaseTable, Sendable {
return unreadCountDictionary
}
switch databaseResult {
case .success(let database):
do {
@@ -717,7 +716,7 @@ nonisolated private extension ArticlesTable {
private func fetchArticles(_ fetchMethod: @escaping ArticlesFetchMethod) throws -> Set<Article> {
nonisolated(unsafe) var articles = Set<Article>()
nonisolated(unsafe) var error: DatabaseError? = nil
nonisolated(unsafe) var error: DatabaseError?
queue.runInDatabaseSync { databaseResult in
switch databaseResult {
@@ -1053,7 +1052,6 @@ nonisolated private extension ArticlesTable {
return updatedArticles
}
func saveUpdatedArticles(_ updatedArticles: Set<Article>, _ fetchedArticles: [String: Article], _ database: FMDatabase) {
saveUpdatedRelatedObjects(updatedArticles, fetchedArticles, database)
@@ -17,7 +17,6 @@ import Articles
// CREATE TABLE if not EXISTS authors (authorID TEXT NOT NULL PRIMARY KEY, name TEXT, url TEXT, avatarURL TEXT, emailAddress TEXT);
// CREATE TABLE if not EXISTS authorLookup (authorID TEXT NOT NULL, articleID TEXT NOT NULL, PRIMARY KEY(authorID, articleID));
final class AuthorsTable: DatabaseRelatedObjectsTable, Sendable {
let name: String
let databaseIDKey = DatabaseKey.authorID
@@ -36,4 +35,3 @@ final class AuthorsTable: DatabaseRelatedObjectsTable, Sendable {
return nil
}
}
@@ -312,7 +312,6 @@ public extension CloudKitZone {
database?.add(op)
}
/// Fetch a CKRecord by using its externalID
func fetch(externalID: String?, completion: @escaping (Result<CKRecord, Error>) -> Void) {
guard let externalID else {
@@ -62,7 +62,7 @@ public struct FeedSpecifier: Hashable, Sendable {
}
var currentHighScore = Int.min
var currentBestFeed: FeedSpecifier? = nil
var currentBestFeed: FeedSpecifier?
for oneFeedSpecifier in feedSpecifiers {
let oneScore = oneFeedSpecifier.score
@@ -14,11 +14,11 @@ import Cocoa
// If provided, the handler will be consulted when the app is moved.
// Return true to indicate that the default handler should be invoked.
public var appMovementHandler: ((RSAppMovementMonitor) -> Bool)? = nil
public var appMovementHandler: ((RSAppMovementMonitor) -> Bool)?
// DispatchSource offers a monitoring mechanism based on an open file descriptor
var fileDescriptor: Int32 = -1
var dispatchSource: DispatchSourceFileSystemObject? = nil
var dispatchSource: DispatchSourceFileSystemObject?
// Save the original location of the app in a file reference URL, which will track its new location.
// Note this is NSURL, not URL, because file reference URLs violate value-type assumptions of URL.
@@ -15,10 +15,10 @@ import AppKit
public final class UserApp {
public let bundleID: String
public var icon: NSImage? = nil
public var icon: NSImage?
public var existsOnDisk = false
public var path: String? = nil
public var runningApplication: NSRunningApplication? = nil
public var path: String?
public var runningApplication: NSRunningApplication?
public var isRunning: Bool {
updateStatus()
+3 -3
View File
@@ -152,9 +152,9 @@ public extension RSImage {
return nil
}
var exactMatch: (index: Int, maxDimension: Int)? = nil
var goodMatch: (index: Int, maxDimension: Int)? = nil
var smallMatch: (index: Int, maxDimension: Int)? = nil
var exactMatch: (index: Int, maxDimension: Int)?
var goodMatch: (index: Int, maxDimension: Int)?
var smallMatch: (index: Int, maxDimension: Int)?
// Single pass through all images to find the best match
for i in 0..<numberOfImages {
@@ -247,7 +247,6 @@ public extension String {
return s.replacingOccurrences(of: "\\n{3,}", with: "\n\n", options: .regularExpression)
}
/// Returns a Boolean value indicating whether the string contains another string, case-insensitively.
///
/// - Parameter string: The string to search for.
@@ -11,7 +11,7 @@
import UIKit
extension UIResponder {
private weak static var _currentFirstResponder: UIResponder? = nil
private weak static var _currentFirstResponder: UIResponder?
public static var isFirstResponderTextField: Bool {
var isTextField = false
@@ -73,7 +73,7 @@ private extension RSSInJSONParser {
let title = itemDictionary["title"] as? String
var contentHTML = itemDictionary["description"] as? String
var contentText: String? = nil
var contentText: String?
if contentHTML != nil && !(contentHTML!.contains("<")) {
contentText = contentHTML
contentHTML = nil
@@ -82,7 +82,7 @@ private extension RSSInJSONParser {
return nil
}
var datePublished: Date? = nil
var datePublished: Date?
if let datePublishedString = itemDictionary["pubDate"] as? String {
datePublished = RSDateWithString(datePublishedString)
}
-1
View File
@@ -164,7 +164,6 @@ import Foundation
}
}
@MainActor public extension Array where Element == Node {
func representedObjects() -> [AnyObject] {
@@ -25,7 +25,6 @@ nonisolated public struct SpecialCase {
}
}
nonisolated extension URL {
public var isOpenRSSOrgURL: Bool {
@@ -148,7 +148,6 @@ final class FeedbinAccountViewController: UITableViewController {
self.present(safari, animated: true, completion: nil)
}
@objc func textDidChange(_ note: Notification) {
actionButton.isEnabled = !(emailTextField.text?.isEmpty ?? false) && !(passwordTextField.text?.isEmpty ?? false)
}
@@ -170,7 +169,6 @@ final class FeedbinAccountViewController: UITableViewController {
activityIndicator.stopAnimating()
}
}
}
extension FeedbinAccountViewController: UITextFieldDelegate {
@@ -184,5 +182,4 @@ extension FeedbinAccountViewController: UITextFieldDelegate {
}
return true
}
}
@@ -116,7 +116,6 @@ final class ReaderAPIAccountViewController: UITableViewController {
}
}
@IBAction func cancel(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
@@ -278,8 +277,6 @@ final class ReaderAPIAccountViewController: UITableViewController {
}
}
@objc func textDidChange(_ note: Notification) {
actionButton.isEnabled = !(usernameTextField.text?.isEmpty ?? false)
}
@@ -315,5 +312,4 @@ extension ReaderAPIAccountViewController: UITextFieldDelegate {
textField.resignFirstResponder()
return true
}
}
-1
View File
@@ -15,7 +15,6 @@ import UIKit
@objc optional func searchBar(_ searchBar: ArticleSearchBar, textDidChange: String)
}
@IBDesignable final class ArticleSearchBar: UIStackView {
var searchField: UISearchTextField!
var nextButton: UIButton!
-1
View File
@@ -428,7 +428,6 @@ extension ArticleViewController {
}
// MARK: WebViewControllerDelegate
extension ArticleViewController: WebViewControllerDelegate {
-1
View File
@@ -238,7 +238,6 @@ open class ImageScrollView: UIScrollView {
minScale = yScale
}
let maxScale = maxScaleFromMinScale*minScale
// don't let minScale exceed maxScale. (If the image is smaller than the screen, we don't want to force it to be zoomed.)
-2
View File
@@ -95,6 +95,4 @@ extension ImageViewController: ImageScrollViewDelegate {
func imageScrollViewDidGestureSwipeDown(imageScrollView: ImageScrollView) {
dismiss(animated: true)
}
}
-3
View File
@@ -505,11 +505,8 @@ extension WebViewController: UIScrollViewDelegate {
self.windowScrollY = javascriptScrollY
}
}
}
// MARK: JSON
private struct ImageClickMessage: Codable {
@@ -43,7 +43,6 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView {
}
}
private var _unreadCount: Int = 0
var unreadCount: Int {
@@ -11,8 +11,7 @@ import RSCore
import Account
import RSTree
class MainFeedCollectionViewCell: UICollectionViewCell {
final class MainFeedCollectionViewCell: UICollectionViewCell {
@IBOutlet var feedTitle: UILabel!
@IBOutlet var faviconView: IconView!
@IBOutlet var unreadCountLabel: UILabel!
@@ -115,6 +114,5 @@ class MainFeedCollectionViewCell: UICollectionViewCell {
}
self.backgroundConfiguration = backgroundConfig
}
}
@@ -97,7 +97,6 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell {
disclosureExpanded = isExpanded
}
override var accessibilityLabel: String? {
set {}
get {
@@ -137,5 +136,4 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell {
self.backgroundConfiguration = backgroundConfig
}
}
@@ -34,7 +34,4 @@ extension MainFeedCollectionViewController: UICollectionViewDragDelegate {
dragItem.localObject = node
return [dragItem]
}
}
@@ -16,7 +16,6 @@ import RSWeb
import SafariServices
import UniformTypeIdentifiers
extension MainFeedCollectionViewController: UICollectionViewDropDelegate {
func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: any UICollectionViewDropCoordinator) {
@@ -57,7 +57,6 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
/// `viewDidAppear(_:)` after a delay to allow the deselection animation to complete.
private var isAnimating: Bool = false
override func viewDidLoad() {
super.viewDidLoad()
registerForNotifications()
@@ -228,7 +227,6 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
return coordinator.numberOfSections()
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of items
return coordinator.numberOfRows(in: section)
@@ -259,7 +257,6 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
for: indexPath
) as! MainFeedCollectionHeaderReusableView
guard let nameProvider = coordinator.rootNode.childAtIndex(indexPath.section)?.representedObject as? DisplayNameProvider else {
return UICollectionReusableView()
}
@@ -301,16 +298,13 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
}
*/
// Uncomment this method to specify if the specified item should be selected
override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
if traitCollection.userInterfaceIdiom == .pad { return true }
return !isAnimating
}
override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {
override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {
return true
}
@@ -339,7 +333,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
// MARK: - Key Commands
// MARK: Keyboard shortcuts
// MARK: - Keyboard shortcuts
@objc func collapseAllExceptForGroupItems(_ sender: Any?) {
coordinator.collapseAllFolders()
@@ -404,8 +398,6 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
coordinator.showFeedInspector()
}
// MARK: - API
func focus() {
@@ -420,11 +412,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
}
addNewItemButton?.isEnabled = !AccountManager.shared.activeAccounts.isEmpty
configureContextMenu()
}
func updateFeedSelection(animations: Animations) {
if let indexPath = coordinator.currentFeedIndexPath {
collectionView.selectItemAndScrollIfNotVisible(at: indexPath, animations: animations)
@@ -550,10 +540,8 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
}
}
// MARK: - Private
/// Configure standard feed cells
func configure(_ cell: MainFeedCollectionViewCell, indexPath: IndexPath) {
guard let node = coordinator.nodeFor(indexPath) else { return }
@@ -612,11 +600,8 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
filterButton?.accLabelText = NSLocalizedString("Filter Read Feeds", comment: "Filter Read Feeds")
}
// MARK: - Notifications
@objc func preferredContentSizeCategoryDidChange() {
IconImageCache.shared.emptyCache()
reloadAllVisibleCells()
@@ -670,8 +655,8 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
}
// MARK: - Actions
@objc
func configureContextMenu(_: Any? = nil) {
@objc func configureContextMenu(_: Any? = nil) {
/*
Context Menu Order:
1. Add Feed
@@ -735,12 +720,10 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
present(alertController, animated: true)
}
@IBAction func toggleFilter(_ sender: Any) {
coordinator.toggleReadFeedsFilter()
}
func toggle(_ headerView: MainFeedCollectionHeaderReusableView) {
guard let sectionNode = coordinator.rootNode.childAtIndex(headerView.tag) else {
return
@@ -754,17 +737,14 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
coordinator.expand(sectionNode)
}
}
}
extension MainFeedCollectionViewController: MainFeedCollectionHeaderReusableViewDelegate {
func mainFeedCollectionHeaderReusableViewDidTapDisclosureIndicator(_ view: MainFeedCollectionHeaderReusableView) {
toggle(view)
}
}
extension MainFeedCollectionViewController: MainFeedCollectionViewFolderCellDelegate {
func mainFeedCollectionFolderViewCellDisclosureDidToggle(_ sender: MainFeedCollectionViewFolderCell, expanding: Bool) {
if expanding {
@@ -774,7 +754,6 @@ extension MainFeedCollectionViewController: MainFeedCollectionViewFolderCellDele
}
}
func expand(_ cell: MainFeedCollectionViewFolderCell) {
guard let indexPath = collectionView.indexPath(for: cell), let node = coordinator.nodeFor(indexPath) else {
return
@@ -788,12 +767,8 @@ extension MainFeedCollectionViewController: MainFeedCollectionViewFolderCellDele
}
coordinator.collapse(node)
}
}
extension MainFeedCollectionViewController: UIContextMenuInteractionDelegate {
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
@@ -825,12 +800,8 @@ extension MainFeedCollectionViewController: UIContextMenuInteractionDelegate {
let cell = collectionView.supplementaryView(forElementKind: UICollectionView.elementKindSectionHeader, at: IndexPath(item: 0, section: sectionIndex)) as? MainFeedCollectionHeaderReusableView else {
return nil
}
return UITargetedPreview(view: cell, parameters: CroppingPreviewParameters(view: cell))
}
}
extension MainFeedCollectionViewController {
@@ -874,9 +845,7 @@ extension MainFeedCollectionViewController {
}
return UIMenu(title: "", children: menuElements)
})
}
func makeFolderContextMenu(indexPath: IndexPath) -> UIContextMenuConfiguration {
@@ -1006,7 +975,6 @@ extension MainFeedCollectionViewController {
completion(true)
}
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
self?.coordinator.markAllAsRead(Array(articles))
@@ -1115,7 +1083,6 @@ extension MainFeedCollectionViewController {
return action
}
func rename(indexPath: IndexPath) {
guard let sidebarItem = coordinator.nodeFor(indexPath)?.representedObject as? SidebarItem else { return }
@@ -1222,4 +1189,3 @@ extension MainFeedCollectionViewController {
deleteCommand.perform()
}
}
@@ -144,6 +144,4 @@ class MainTimelineFeedCell: UITableViewCell {
self.backgroundConfiguration = backgroundConfig
}
}
@@ -46,7 +46,6 @@ class MainTimelineIconFeedCell: UITableViewCell {
}
}
private func configure(_ cellData: MainTimelineCellData) {
updateIndicatorView(cellData)
articleTitle.numberOfLines = cellData.numberOfLines
@@ -117,8 +116,6 @@ class MainTimelineIconFeedCell: UITableViewCell {
private func applyTitleTextWithAttributes(_ state: UICellConfigurationState) {
let attributedCellText = NSMutableAttributedString()
let isSelected = state.isSelected || state.isHighlighted || state.isFocused || state.isSwiped
if cellData.title != "" {
let paragraphStyle = NSMutableParagraphStyle()
@@ -1018,7 +1018,6 @@ private extension MainTimelineViewController {
return nil
}
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
@@ -14,7 +14,6 @@ extension CGRect: MarkAsReadAlertControllerSourceType {}
extension UIView: MarkAsReadAlertControllerSourceType {}
extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {}
@MainActor struct MarkAsReadAlertController {
static func confirm<T>(_ controller: UIViewController?,
@@ -45,7 +44,6 @@ extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {}
sourceType: T,
completion: @escaping (UIAlertAction) -> Void) -> UIAlertController where T: MarkAsReadAlertControllerSourceType {
let title = NSLocalizedString("Mark As Read", comment: "Mark As Read")
let message = NSLocalizedString("You can turn this confirmation off in Settings.",
comment: "You can turn this confirmation off in Settings.")
-4
View File
@@ -583,7 +583,6 @@ struct FeedNode: Hashable, Sendable {
}
}
/// Updates navigation bar subtitles in response to feed selection, unread count changes,
/// `combinedRefreshProgressDidChange` notifications, and a timed refresh every
/// 60s.
@@ -906,7 +905,6 @@ struct FeedNode: Hashable, Sendable {
currentFeedIndexPath = indexPath
mainFeedCollectionViewController.updateFeedSelection(animations: animations)
if deselectArticle {
selectArticle(nil)
}
@@ -937,7 +935,6 @@ struct FeedNode: Hashable, Sendable {
}
updateNavigationBarSubtitles(nil)
}
func selectPrevFeed() {
@@ -2291,7 +2288,6 @@ private extension SceneCoordinator {
let isShowingExtractedArticle = AppDefaults.shared.isShowingExtractedArticle
let articleWindowScrollY = AppDefaults.shared.articleWindowScrollY
switch sidebarItemID {
case .smartFeed, .folder:
-2
View File
@@ -214,8 +214,6 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
} else {
return
}
}
}
}
@@ -83,7 +83,6 @@ final class ModernTimelineCustomizerTableViewController: UITableViewController {
return cell
}
if indexPath.section == 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: "MainTimelineIconFeedCell") as? MainTimelineIconFeedCell ?? MainTimelineIconFeedCell()
cell.cellData = MainTimelineCellData(article: previewArticle,
+3 -4
View File
@@ -318,8 +318,7 @@ final class SettingsViewController: UITableViewController {
AppDefaults.shared.isArticleContentJavascriptEnabled = enableJavaScriptSwitch.isOn
}
// MARK: Notifications
// MARK: - Notifications
@objc func contentSizeCategoryDidChange() {
tableView.reloadData()
@@ -339,7 +338,7 @@ final class SettingsViewController: UITableViewController {
}
// MARK: OPML Document Picker
// MARK: - OPML Document Picker
extension SettingsViewController: UIDocumentPickerDelegate {
@@ -360,7 +359,7 @@ extension SettingsViewController: UIDocumentPickerDelegate {
}
// MARK: Private
// MARK: - Private
private extension SettingsViewController {
+1 -5
View File
@@ -36,7 +36,6 @@ final class ShareViewController: SLComposeServiceViewController, ShareFolderPick
}
override func viewDidLoad() {
extensionContainers = ExtensionContainersFile.read()
flattenedContainers = extensionContainers?.flattened ?? [ExtensionContainer]()
if let extensionContainers {
@@ -115,7 +114,7 @@ final class ShareViewController: SLComposeServiceViewController, ShareFolderPick
}
override func didSelectPost() {
guard let url = url, let selectedContainer = selectedContainer, let containerID = selectedContainer.containerID else {
guard let url, let selectedContainer, let containerID = selectedContainer.containerID else {
self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
return
}
@@ -139,7 +138,6 @@ final class ShareViewController: SLComposeServiceViewController, ShareFolderPick
}
override func configurationItems() -> [Any]! {
// To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
guard let urlItem = SLComposeSheetConfigurationItem() else { return nil }
urlItem.title = "URL"
@@ -165,7 +163,6 @@ final class ShareViewController: SLComposeServiceViewController, ShareFolderPick
return [folderItem!, urlItem]
}
}
private extension ShareViewController {
@@ -177,5 +174,4 @@ private extension ShareViewController {
self.folderItem.value = "\(folder.accountName) / \(folder.name)"
}
}
}