diff --git a/Account/Sources/Account/Folder.swift b/Account/Sources/Account/Folder.swift index f7d178ed1..07bb8c8cc 100644 --- a/Account/Sources/Account/Folder.swift +++ b/Account/Sources/Account/Folder.swift @@ -24,7 +24,7 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable { return ContainerIdentifier.folder(accountID, nameForDisplay) } - public var feedID: SidebarItemIdentifier? { + public var sidebarItemID: SidebarItemIdentifier? { guard let accountID = account?.accountID else { assertionFailure("Expected feed.account, but got nil.") return nil diff --git a/Account/Sources/Account/SidebarItem.swift b/Account/Sources/Account/SidebarItem.swift index df717a66a..c3a5c8468 100644 --- a/Account/Sources/Account/SidebarItem.swift +++ b/Account/Sources/Account/SidebarItem.swift @@ -28,7 +28,7 @@ public extension SidebarItem { guard defaultReadFilterType != .alwaysRead else { return true } - if let feedID = feedID, let readFilterEnabled = readFilterEnabledTable[feedID] { + if let sidebarItemID, let readFilterEnabled = readFilterEnabledTable[sidebarItemID] { return readFilterEnabled } else { return defaultReadFilterType == .read diff --git a/Account/Sources/Account/SidebarItemIdentifier.swift b/Account/Sources/Account/SidebarItemIdentifier.swift index 65e05efd0..2af20201e 100644 --- a/Account/Sources/Account/SidebarItemIdentifier.swift +++ b/Account/Sources/Account/SidebarItemIdentifier.swift @@ -9,7 +9,7 @@ import Foundation public protocol SidebarItemIdentifiable { - var feedID: SidebarItemIdentifier? { get } + var sidebarItemID: SidebarItemIdentifier? { get } } public enum SidebarItemIdentifier: CustomStringConvertible, Hashable, Equatable { diff --git a/Account/Sources/Account/WebFeed.swift b/Account/Sources/Account/WebFeed.swift index 1e64dd32c..b38ebdbce 100644 --- a/Account/Sources/Account/WebFeed.swift +++ b/Account/Sources/Account/WebFeed.swift @@ -17,7 +17,7 @@ public final class WebFeed: SidebarItem, Renamable, Hashable { return .none } - public var feedID: SidebarItemIdentifier? { + public var sidebarItemID: SidebarItemIdentifier? { guard let accountID = account?.accountID else { assertionFailure("Expected feed.account, but got nil.") return nil diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index 91b911c3e..c5ddf3789 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -97,7 +97,7 @@ protocol SidebarDelegate: AnyObject { func saveState(to state: inout [AnyHashable : Any]) { state[UserInfoKey.readFeedsFilterState] = isReadFiltered state[UserInfoKey.containerExpandedWindowState] = expandedTable.map { $0.userInfo } - state[UserInfoKey.selectedFeedsState] = selectedFeeds.compactMap { $0.feedID?.userInfo } + state[UserInfoKey.selectedFeedsState] = selectedFeeds.compactMap { $0.sidebarItemID?.userInfo } } func restoreState(from state: [AnyHashable : Any]) { @@ -119,8 +119,8 @@ protocol SidebarDelegate: AnyObject { var selectIndexes = IndexSet() func selectFeedsVisitor(node: Node) { - if let feedID = (node.representedObject as? SidebarItemIdentifiable)?.feedID { - if selectedFeedIdentifers.contains(feedID) { + if let sidebarItemID = (node.representedObject as? SidebarItemIdentifiable)?.sidebarItemID { + if selectedFeedIdentifers.contains(sidebarItemID) { selectIndexes.insert(outlineView.row(forItem: node) ) } } @@ -448,12 +448,12 @@ protocol SidebarDelegate: AnyObject { // MARK: - API func selectFeed(_ feed: SidebarItem) { - if isReadFiltered, let feedID = feed.feedID { - self.treeControllerDelegate.addFilterException(feedID) - + if isReadFiltered, let sidebarItemID = feed.sidebarItemID { + self.treeControllerDelegate.addFilterException(sidebarItemID) + if let webFeed = feed as? WebFeed, let account = webFeed.account { let parentFolder = account.sortedFolders?.first(where: { $0.objectIsChild(webFeed) }) - if let parentFolderFeedID = parentFolder?.feedID { + if let parentFolderFeedID = parentFolder?.sidebarItemID { self.treeControllerDelegate.addFilterException(parentFolderFeedID) } } @@ -536,16 +536,16 @@ private extension SidebarViewController { } func addToFilterExeptionsIfNecessary(_ feed: SidebarItem?) { - if isReadFiltered, let feedID = feed?.feedID { + if isReadFiltered, let sidebarItemID = feed?.sidebarItemID { if feed is PseudoFeed { - treeControllerDelegate.addFilterException(feedID) + treeControllerDelegate.addFilterException(sidebarItemID) } else if let folderFeed = feed as? Folder { if folderFeed.account?.existingFolder(withID: folderFeed.folderID) != nil { - treeControllerDelegate.addFilterException(feedID) + treeControllerDelegate.addFilterException(sidebarItemID) } } else if let webFeed = feed as? WebFeed { if webFeed.account?.existingWebFeed(withWebFeedID: webFeed.webFeedID) != nil { - treeControllerDelegate.addFilterException(feedID) + treeControllerDelegate.addFilterException(sidebarItemID) addParentFolderToFilterExceptions(webFeed) } } @@ -555,11 +555,11 @@ private extension SidebarViewController { func addParentFolderToFilterExceptions(_ feed: SidebarItem) { guard let node = treeController.rootNode.descendantNodeRepresentingObject(feed as AnyObject), let folder = node.parent?.representedObject as? Folder, - let folderFeedID = folder.feedID else { + let folderSidebarItemID = folder.sidebarItemID else { return } - treeControllerDelegate.addFilterException(folderFeedID) + treeControllerDelegate.addFilterException(folderSidebarItemID) } @@ -613,8 +613,8 @@ private extension SidebarViewController { } func addTreeControllerToFilterExceptionsVisitor(node: Node) { - if let feed = node.representedObject as? SidebarItem, let feedID = feed.feedID { - treeControllerDelegate.addFilterException(feedID) + if let sidebarItem = node.representedObject as? SidebarItem, let sidebarItemID = sidebarItem.sidebarItemID { + treeControllerDelegate.addFilterException(sidebarItemID) } } diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index b93903d1d..2d730ffb1 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -36,7 +36,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr guard timelineFeed.defaultReadFilterType != .alwaysRead else { return nil } - if let feedID = timelineFeed.feedID, let readFilterEnabled = readFilterEnabledTable[feedID] { + if let sidebarItemID = timelineFeed.sidebarItemID, let readFilterEnabled = readFilterEnabledTable[sidebarItemID] { return readFilterEnabled } else { return timelineFeed.defaultReadFilterType == .read @@ -263,8 +263,8 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } func toggleReadFilter() { - guard let filter = isReadFiltered, let feedID = (representedObjects?.first as? SidebarItem)?.feedID else { return } - readFilterEnabledTable[feedID] = !filter + guard let filter = isReadFiltered, let sidebarItemID = (representedObjects?.first as? SidebarItem)?.sidebarItemID else { return } + readFilterEnabledTable[sidebarItemID] = !filter delegate?.timelineInvalidatedRestorationState(self) fetchAndReplacePreservingSelection() } diff --git a/Shared/Activity/ActivityManager.swift b/Shared/Activity/ActivityManager.swift index a428506af..f624ccaaa 100644 --- a/Shared/Activity/ActivityManager.swift +++ b/Shared/Activity/ActivityManager.swift @@ -172,16 +172,16 @@ private extension ActivityManager { activity.keywords = Set(makeKeywords(title)) activity.isEligibleForSearch = true - let articleFetcherIdentifierUserInfo = feed.feedID?.userInfo ?? [AnyHashable: Any]() + let articleFetcherIdentifierUserInfo = feed.sidebarItemID?.userInfo ?? [AnyHashable: Any]() activity.userInfo = [UserInfoKey.feedIdentifier: articleFetcherIdentifierUserInfo] activity.requiredUserInfoKeys = Set(activity.userInfo!.keys.map { $0 as! String }) - activity.persistentIdentifier = feed.feedID?.description ?? "" + activity.persistentIdentifier = feed.sidebarItemID?.description ?? "" #if os(iOS) activity.suggestedInvocationPhrase = title activity.isEligibleForPrediction = true - activity.contentAttributeSet?.relatedUniqueIdentifier = feed.feedID?.description ?? "" + activity.contentAttributeSet?.relatedUniqueIdentifier = feed.sidebarItemID?.description ?? "" #endif return activity @@ -192,7 +192,7 @@ private extension ActivityManager { activity.title = ArticleStringFormatter.truncatedTitle(article) if let feed = feed { - let articleFetcherIdentifierUserInfo = feed.feedID?.userInfo ?? [AnyHashable: Any]() + let articleFetcherIdentifierUserInfo = feed.sidebarItemID?.userInfo ?? [AnyHashable: Any]() let articlePathUserInfo = article.pathUserInfo activity.userInfo = [UserInfoKey.feedIdentifier: articleFetcherIdentifierUserInfo, UserInfoKey.articlePath: articlePathUserInfo] } else { diff --git a/Shared/IconImageCache.swift b/Shared/IconImageCache.swift index 1245784c5..ad56abecf 100644 --- a/Shared/IconImageCache.swift +++ b/Shared/IconImageCache.swift @@ -30,19 +30,19 @@ class IconImageCache { return nil } - func imageForFeed(_ feed: SidebarItem) -> IconImage? { - guard let feedID = feed.feedID else { + func imageForFeed(_ sidebarItem: SidebarItem) -> IconImage? { + guard let sidebarItemID = sidebarItem.sidebarItemID else { return nil } - if let smartFeed = feed as? PseudoFeed { - return imageForSmartFeed(smartFeed, feedID) + if let smartFeed = sidebarItem as? PseudoFeed { + return imageForSmartFeed(smartFeed, sidebarItemID) } - if let webFeed = feed as? WebFeed, let iconImage = imageForWebFeed(webFeed, feedID) { + if let webFeed = sidebarItem as? WebFeed, let iconImage = imageForWebFeed(webFeed, sidebarItemID) { return iconImage } - if let smallIconProvider = feed as? SmallIconProvider { - return imageForSmallIconProvider(smallIconProvider, feedID) + if let smallIconProvider = sidebarItem as? SmallIconProvider { + return imageForSmallIconProvider(smallIconProvider, sidebarItemID) } return nil diff --git a/Shared/SmartFeeds/SearchFeedDelegate.swift b/Shared/SmartFeeds/SearchFeedDelegate.swift index aa1c633d2..cc8060725 100644 --- a/Shared/SmartFeeds/SearchFeedDelegate.swift +++ b/Shared/SmartFeeds/SearchFeedDelegate.swift @@ -14,7 +14,7 @@ import ArticlesDatabase struct SearchFeedDelegate: SmartFeedDelegate { - var feedID: SidebarItemIdentifier? { + var sidebarItemID: SidebarItemIdentifier? { return SidebarItemIdentifier.smartFeed(String(describing: SearchFeedDelegate.self)) } diff --git a/Shared/SmartFeeds/SearchTimelineFeedDelegate.swift b/Shared/SmartFeeds/SearchTimelineFeedDelegate.swift index dac7fb49c..53acc7a50 100644 --- a/Shared/SmartFeeds/SearchTimelineFeedDelegate.swift +++ b/Shared/SmartFeeds/SearchTimelineFeedDelegate.swift @@ -14,7 +14,7 @@ import ArticlesDatabase struct SearchTimelineFeedDelegate: SmartFeedDelegate { - var feedID: SidebarItemIdentifier? { + var sidebarItemID: SidebarItemIdentifier? { return SidebarItemIdentifier.smartFeed(String(describing: SearchTimelineFeedDelegate.self)) } diff --git a/Shared/SmartFeeds/SmartFeed.swift b/Shared/SmartFeeds/SmartFeed.swift index fac85807a..a31473f19 100644 --- a/Shared/SmartFeeds/SmartFeed.swift +++ b/Shared/SmartFeeds/SmartFeed.swift @@ -20,8 +20,8 @@ final class SmartFeed: PseudoFeed { return .none } - var feedID: SidebarItemIdentifier? { - delegate.feedID + var sidebarItemID: SidebarItemIdentifier? { + delegate.sidebarItemID } var nameForDisplay: String { diff --git a/Shared/SmartFeeds/StarredFeedDelegate.swift b/Shared/SmartFeeds/StarredFeedDelegate.swift index 23d1be80c..1eae46c08 100644 --- a/Shared/SmartFeeds/StarredFeedDelegate.swift +++ b/Shared/SmartFeeds/StarredFeedDelegate.swift @@ -16,7 +16,7 @@ import Account struct StarredFeedDelegate: SmartFeedDelegate { - var feedID: SidebarItemIdentifier? { + var sidebarItemID: SidebarItemIdentifier? { return SidebarItemIdentifier.smartFeed(String(describing: StarredFeedDelegate.self)) } diff --git a/Shared/SmartFeeds/TodayFeedDelegate.swift b/Shared/SmartFeeds/TodayFeedDelegate.swift index a3b1bceaf..06f215ef5 100644 --- a/Shared/SmartFeeds/TodayFeedDelegate.swift +++ b/Shared/SmartFeeds/TodayFeedDelegate.swift @@ -14,7 +14,7 @@ import Account struct TodayFeedDelegate: SmartFeedDelegate { - var feedID: SidebarItemIdentifier? { + var sidebarItemID: SidebarItemIdentifier? { return SidebarItemIdentifier.smartFeed(String(describing: TodayFeedDelegate.self)) } diff --git a/Shared/SmartFeeds/UnreadFeed.swift b/Shared/SmartFeeds/UnreadFeed.swift index a758b1876..540eb9620 100644 --- a/Shared/SmartFeeds/UnreadFeed.swift +++ b/Shared/SmartFeeds/UnreadFeed.swift @@ -26,7 +26,7 @@ final class UnreadFeed: PseudoFeed { return .alwaysRead } - var feedID: SidebarItemIdentifier? { + var sidebarItemID: SidebarItemIdentifier? { return SidebarItemIdentifier.smartFeed(String(describing: UnreadFeed.self)) } diff --git a/Shared/Tree/WebFeedTreeControllerDelegate.swift b/Shared/Tree/WebFeedTreeControllerDelegate.swift index 1bc6240f8..31f7a59ae 100644 --- a/Shared/Tree/WebFeedTreeControllerDelegate.swift +++ b/Shared/Tree/WebFeedTreeControllerDelegate.swift @@ -67,14 +67,14 @@ private extension WebFeedTreeControllerDelegate { var children = [AnyObject]() for webFeed in container.topLevelWebFeeds { - if let feedID = webFeed.feedID, !(!filterExceptions.contains(feedID) && isReadFiltered && webFeed.unreadCount == 0) { + if let sidebarItemID = webFeed.sidebarItemID, !(!filterExceptions.contains(sidebarItemID) && isReadFiltered && webFeed.unreadCount == 0) { children.append(webFeed) } } if let folders = container.folders { for folder in folders { - if let feedID = folder.feedID, !(!filterExceptions.contains(feedID) && isReadFiltered && folder.unreadCount == 0) { + if let sidebarItemID = folder.sidebarItemID, !(!filterExceptions.contains(sidebarItemID) && isReadFiltered && folder.unreadCount == 0) { children.append(folder) } } diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 2ec52d7ce..37107fdfe 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -798,10 +798,10 @@ private extension MasterFeedViewController { } func configureIcon(_ cell: MasterFeedTableViewCell, _ indexPath: IndexPath) { - guard let node = coordinator.nodeFor(indexPath), let feed = node.representedObject as? SidebarItem, let feedID = feed.feedID else { + guard let node = coordinator.nodeFor(indexPath), let feed = node.representedObject as? SidebarItem, let sidebarItemID = feed.sidebarItemID else { return } - cell.iconImage = IconImageCache.shared.imageFor(feedID) + cell.iconImage = IconImageCache.shared.imageFor(sidebarItemID) } func nameFor(_ node: Node) -> String { @@ -820,7 +820,7 @@ private extension MasterFeedViewController { if let node = coordinator.nodeFor(indexPath), let representedFeed = representedObject as? SidebarItem, let candidate = node.representedObject as? SidebarItem, - representedFeed.feedID == candidate.feedID { + representedFeed.sidebarItemID == candidate.sidebarItemID { completion(cell, indexPath) } } diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index e8e26966e..b09b2f76d 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -34,10 +34,10 @@ enum ShowFeedName { struct FeedNode: Hashable { var node: Node var feedID: SidebarItemIdentifier - + init(_ node: Node) { self.node = node - self.feedID = (node.representedObject as! SidebarItem).feedID! + self.feedID = (node.representedObject as! SidebarItem).sidebarItemID! } func hash(into hasher: inout Hasher) { @@ -149,7 +149,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner { } var isReadArticlesFiltered: Bool { - if let feedID = timelineFeed?.feedID, let readFilterEnabled = readFilterEnabledTable[feedID] { + if let sidebarItemID = timelineFeed?.sidebarItemID, let readFilterEnabled = readFilterEnabledTable[sidebarItemID] { return readFilterEnabled } else { return timelineDefaultReadFilterType != .none @@ -617,23 +617,23 @@ class SceneCoordinator: NSObject, UndoableCommandRunner { } func toggleReadArticlesFilter() { - guard let feedID = timelineFeed?.feedID else { + guard let sidebarItemID = timelineFeed?.sidebarItemID else { return } if isReadArticlesFiltered { - readFilterEnabledTable[feedID] = false + readFilterEnabledTable[sidebarItemID] = false } else { - readFilterEnabledTable[feedID] = true + readFilterEnabledTable[sidebarItemID] = true } refreshTimeline(resetScroll: false) } - func nodeFor(feedID: SidebarItemIdentifier) -> Node? { + func nodeFor(sidebarItemID: SidebarItemIdentifier) -> Node? { return treeController.rootNode.descendantNode(where: { node in if let feed = node.representedObject as? SidebarItem { - return feed.feedID == feedID + return feed.sidebarItemID == sidebarItemID } else { return false } @@ -1128,10 +1128,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner { markExpanded(parentFolder) } - if let webFeedFeedID = webFeed.feedID { + if let webFeedFeedID = webFeed.sidebarItemID { self.treeControllerDelegate.addFilterException(webFeedFeedID) } - if let parentFolderFeedID = parentFolder?.feedID { + if let parentFolderFeedID = parentFolder?.sidebarItemID { self.treeControllerDelegate.addFilterException(parentFolderFeedID) } @@ -1450,16 +1450,16 @@ private extension SceneCoordinator { } func addToFilterExeptionsIfNecessary(_ feed: SidebarItem?) { - if isReadFeedsFiltered, let feedID = feed?.feedID { + if isReadFeedsFiltered, let sidebarItemID = feed?.sidebarItemID { if feed is SmartFeed { - treeControllerDelegate.addFilterException(feedID) + treeControllerDelegate.addFilterException(sidebarItemID) } else if let folderFeed = feed as? Folder { if folderFeed.account?.existingFolder(withID: folderFeed.folderID) != nil { - treeControllerDelegate.addFilterException(feedID) + treeControllerDelegate.addFilterException(sidebarItemID) } } else if let webFeed = feed as? WebFeed { if webFeed.account?.existingWebFeed(withWebFeedID: webFeed.webFeedID) != nil { - treeControllerDelegate.addFilterException(feedID) + treeControllerDelegate.addFilterException(sidebarItemID) addParentFolderToFilterExceptions(webFeed) } } @@ -1469,7 +1469,7 @@ private extension SceneCoordinator { func addParentFolderToFilterExceptions(_ feed: SidebarItem) { guard let node = treeController.rootNode.descendantNodeRepresentingObject(feed as AnyObject), let folder = node.parent?.representedObject as? Folder, - let folderFeedID = folder.feedID else { + let folderFeedID = folder.sidebarItemID else { return } @@ -1479,7 +1479,7 @@ private extension SceneCoordinator { func addShadowTableToFilterExceptions() { for section in shadowTable { for feedNode in section.feedNodes { - if let feed = feedNode.node.representedObject as? SidebarItem, let feedID = feed.feedID { + if let feed = feedNode.node.representedObject as? SidebarItem, let feedID = feed.sidebarItemID { treeControllerDelegate.addFilterException(feedID) } } @@ -1598,7 +1598,7 @@ private extension SceneCoordinator { func shadowTableContains(_ feed: SidebarItem) -> Bool { for section in shadowTable { for feedNode in section.feedNodes { - if let nodeFeed = feedNode.node.representedObject as? SidebarItem, nodeFeed.feedID == feed.feedID { + if let nodeFeed = feedNode.node.representedObject as? SidebarItem, nodeFeed.sidebarItemID == feed.sidebarItemID { return true } } @@ -2316,7 +2316,7 @@ private extension SceneCoordinator { let found = selectFeedAndArticle(feedIdentifier: feedIdentifier, articleID: articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY) if found { treeControllerDelegate.addFilterException(feedIdentifier) - if let webFeedNode = nodeFor(feedID: feedIdentifier), let folder = webFeedNode.parent?.representedObject as? Folder, let folderFeedID = folder.feedID { + if let webFeedNode = nodeFor(sidebarItemID: feedIdentifier), let folder = webFeedNode.parent?.representedObject as? Folder, let folderFeedID = folder.sidebarItemID { treeControllerDelegate.addFilterException(folderFeedID) } } @@ -2353,7 +2353,7 @@ private extension SceneCoordinator { } func selectFeedAndArticle(feedIdentifier: SidebarItemIdentifier, articleID: String, isShowingExtractedArticle: Bool, articleWindowScrollY: Int) -> Bool { - guard let feedNode = nodeFor(feedID: feedIdentifier), let feedIndexPath = indexPathFor(feedNode) else { return false } + guard let feedNode = nodeFor(sidebarItemID: feedIdentifier), let feedIndexPath = indexPathFor(feedNode) else { return false } selectFeed(indexPath: feedIndexPath) { self.selectArticleInCurrentFeed(articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY)