Rename WebFeed type to just Feed.

This commit is contained in:
Brent Simmons
2023-07-05 10:02:53 -07:00
parent d5d57a7e30
commit 2f07f4ee16
50 changed files with 393 additions and 393 deletions

View File

@@ -13,7 +13,7 @@ import UserNotifications
struct WebFeedInspectorView: View {
var webFeed: WebFeed!
var webFeed: Feed!
@State private var showHomePage: Bool = false
var body: some View {

View File

@@ -14,7 +14,7 @@ import UniformTypeIdentifiers
extension MasterFeedViewController: UITableViewDragDelegate {
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
guard let node = coordinator.nodeFor(indexPath), let webFeed = node.representedObject as? WebFeed else {
guard let node = coordinator.nodeFor(indexPath), let webFeed = node.representedObject as? Feed else {
return [UIDragItem]()
}

View File

@@ -23,7 +23,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
}
guard let sourceNode = session.localDragSession?.items.first?.localObject as? Node,
let sourceWebFeed = sourceNode.representedObject as? WebFeed else {
let sourceWebFeed = sourceNode.representedObject as? Feed else {
return UITableViewDropProposal(operation: .forbidden)
}
@@ -114,7 +114,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
}
}()
guard let destination = destinationContainer, let webFeed = dragNode.representedObject as? WebFeed else { return }
guard let destination = destinationContainer, let webFeed = dragNode.representedObject as? Feed else { return }
if source.account == destination.account {
moveFeedInAccount(feed: webFeed, sourceContainer: source, destinationContainer: destination)
@@ -138,7 +138,7 @@ private extension MasterFeedViewController {
return correctDestination
}
func moveFeedInAccount(feed: WebFeed, sourceContainer: Container, destinationContainer: Container) {
func moveFeedInAccount(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
guard sourceContainer !== destinationContainer else { return }
BatchUpdate.shared.start()
@@ -153,7 +153,7 @@ private extension MasterFeedViewController {
}
}
func copyWebFeedBetweenAccounts(feed: WebFeed, sourceContainer: Container, destinationContainer: Container) {
func copyWebFeedBetweenAccounts(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
if let existingFeed = destinationContainer.account?.existingFeed(withURL: feed.url) {

View File

@@ -144,17 +144,17 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner, Ma
}
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
guard let webFeed = note.userInfo?[UserInfoKey.webFeed] as? WebFeed else {
guard let webFeed = note.userInfo?[UserInfoKey.webFeed] as? Feed else {
return
}
applyToCellsForRepresentedObject(webFeed, configureIcon(_:_:))
}
@objc func webFeedSettingDidChange(_ note: Notification) {
guard let webFeed = note.object as? WebFeed, let key = note.userInfo?[WebFeed.FeedSettingUserInfoKey] as? String else {
guard let webFeed = note.object as? Feed, let key = note.userInfo?[Feed.FeedSettingUserInfoKey] as? String else {
return
}
if key == WebFeed.FeedSettingKey.homePageURL || key == WebFeed.FeedSettingKey.faviconURL {
if key == Feed.FeedSettingKey.homePageURL || key == Feed.FeedSettingKey.faviconURL {
configureCellsForRepresentedObject(webFeed)
}
}
@@ -285,7 +285,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner, Ma
renameAction.backgroundColor = UIColor.systemOrange
actions.append(renameAction)
if let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed {
if let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed {
let moreTitle = NSLocalizedString("action.title.more", comment: "More")
let moreAction = UIContextualAction(style: .normal, title: moreTitle) { [weak self] (action, view, completion) in
@@ -340,7 +340,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner, Ma
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? FeedProtocol else {
return nil
}
if feed is WebFeed {
if feed is Feed {
return makeWebFeedContextMenu(indexPath: indexPath, includeDeleteRename: true)
} else if feed is Folder {
return makeFolderContextMenu(indexPath: indexPath)
@@ -850,7 +850,7 @@ private extension MasterFeedViewController {
}
func configureIcon(_ cell: MasterFeedTableViewCell, _ indexPath: IndexPath) {
guard let node = coordinator.nodeFor(indexPath), let feed = node.representedObject as? FeedProtocol, let feedID = feed.feedID else {
guard let node = coordinator.nodeFor(indexPath), let feed = node.representedObject as? FeedProtocol, let feedID = feed.itemID else {
return
}
cell.iconImage = IconImageCache.shared.imageFor(feedID)
@@ -872,7 +872,7 @@ private extension MasterFeedViewController {
if let node = coordinator.nodeFor(indexPath),
let representedFeed = representedObject as? FeedProtocol,
let candidate = node.representedObject as? FeedProtocol,
representedFeed.feedID == candidate.feedID {
representedFeed.itemID == candidate.itemID {
completion(cell, indexPath)
}
}
@@ -906,7 +906,7 @@ private extension MasterFeedViewController {
if let folder = node.representedObject as? Folder {
return folder.account
}
if let feed = node.representedObject as? WebFeed {
if let feed = node.representedObject as? Feed {
return feed.account
}
return nil
@@ -1062,7 +1062,7 @@ private extension MasterFeedViewController {
}
func copyFeedPageAction(indexPath: IndexPath) -> UIAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed,
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let url = URL(string: webFeed.url) else {
return nil
}
@@ -1075,7 +1075,7 @@ private extension MasterFeedViewController {
}
func copyFeedPageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed,
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let url = URL(string: webFeed.url) else {
return nil
}
@@ -1089,7 +1089,7 @@ private extension MasterFeedViewController {
}
func copyHomePageAction(indexPath: IndexPath) -> UIAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed,
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let homePageURL = webFeed.homePageURL,
let url = URL(string: homePageURL) else {
return nil
@@ -1103,7 +1103,7 @@ private extension MasterFeedViewController {
}
func copyHomePageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed,
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let homePageURL = webFeed.homePageURL,
let url = URL(string: homePageURL) else {
return nil
@@ -1118,7 +1118,7 @@ private extension MasterFeedViewController {
}
func markAllAsReadAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed,
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
webFeed.unreadCount > 0,
let articles = try? webFeed.fetchArticles(), let contentView = self.tableView.cellForRow(at: indexPath)?.contentView else {
return nil
@@ -1157,7 +1157,7 @@ private extension MasterFeedViewController {
}
func getInfoAction(indexPath: IndexPath) -> UIAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed else {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else {
return nil
}
@@ -1185,7 +1185,7 @@ private extension MasterFeedViewController {
}
func getInfoAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? WebFeed else {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else {
return nil
}
@@ -1442,7 +1442,7 @@ private extension MasterFeedViewController {
return
}
if let webFeed = feed as? WebFeed {
if let webFeed = feed as? Feed {
webFeed.rename(to: name) { result in
switch result {
case .success:
@@ -1517,7 +1517,7 @@ private extension MasterFeedViewController {
if let folder = deleteNode.representedObject as? Folder {
ActivityManager.cleanUp(folder)
} else if let feed = deleteNode.representedObject as? WebFeed {
} else if let feed = deleteNode.representedObject as? Feed {
ActivityManager.cleanUp(feed)
}

View File

@@ -473,7 +473,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
titleView.iconView.iconImage = coordinator.timelineIconImage
}
guard let feed = note.userInfo?[UserInfoKey.webFeed] as? WebFeed else {
guard let feed = note.userInfo?[UserInfoKey.webFeed] as? Feed else {
return
}
tableView.indexPathsForVisibleRows?.forEach { indexPath in
@@ -564,7 +564,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
let prototypeID = "prototype"
let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date())
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, webFeedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status)
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status)
let prototypeCellData = MasterTimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Prototype Feed Name", byline: nil, iconImage: nil, showIcon: false, featuredImage: nil, numberOfLines: numberOfTextLines, iconSize: iconSize, hideSeparator: false)
@@ -640,7 +640,7 @@ private extension MasterTimelineViewController {
titleView.label.text = coordinator.timelineFeed?.nameForDisplay
updateTitleUnreadCount()
if coordinator.timelineFeed is WebFeed {
if coordinator.timelineFeed is Feed {
titleView.buttonize()
titleView.addGestureRecognizer(feedTapGestureRecognizer)
} else {

View File

@@ -45,11 +45,11 @@ struct FeedNode: Hashable {
guard let feed = node.representedObject as? FeedProtocol else { return nil }
self.node = node
self.feedID = feed.feedID!
self.itemID = feed.itemID!
}
func hash(into hasher: inout Hasher) {
hasher.combine(feedID)
hasher.combine(itemID)
}
}
@@ -141,7 +141,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
}
var isReadArticlesFiltered: Bool {
if let feedID = timelineFeed?.feedID, let readFilterEnabled = readFilterEnabledTable[feedID] {
if let feedID = timelineFeed?.itemID, let readFilterEnabled = readFilterEnabledTable[feedID] {
return readFilterEnabled
} else {
return timelineDefaultReadFilterType != .none
@@ -513,7 +513,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
}
@objc func userDidAddFeed(_ notification: Notification) {
guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? WebFeed else {
guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? Feed else {
return
}
discloseWebFeed(webFeed, animations: [.scroll, .navigation])
@@ -525,7 +525,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
}
@objc func accountDidDownloadArticles(_ note: Notification) {
guard let feeds = note.userInfo?[Account.UserInfoKey.webFeeds] as? Set<WebFeed> else {
guard let feeds = note.userInfo?[Account.UserInfoKey.webFeeds] as? Set<Feed> else {
return
}
@@ -605,7 +605,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
}
func toggleReadArticlesFilter() {
guard let feedID = timelineFeed?.feedID else {
guard let feedID = timelineFeed?.itemID else {
return
}
@@ -1119,15 +1119,15 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
markArticlesWithUndo([article], statusKey: .starred, flag: !article.status.starred, directlyMarked: true)
}
func timelineFeedIsEqualTo(_ feed: WebFeed) -> Bool {
guard let timelineFeed = timelineFeed as? WebFeed else {
func timelineFeedIsEqualTo(_ feed: Feed) -> Bool {
guard let timelineFeed = timelineFeed as? Feed else {
return false
}
return timelineFeed == feed
}
func discloseWebFeed(_ webFeed: WebFeed, initialLoad: Bool = false, animations: Animations = [], completion: (() -> Void)? = nil) {
func discloseWebFeed(_ webFeed: Feed, initialLoad: Bool = false, animations: Animations = [], completion: (() -> Void)? = nil) {
if isSearching {
masterTimelineViewController?.hideSearch()
}
@@ -1144,10 +1144,10 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
markExpanded(parentFolder)
}
if let webFeedFeedID = webFeed.feedID {
if let webFeedFeedID = webFeed.itemID {
self.treeControllerDelegate.addFilterException(webFeedFeedID)
}
if let parentFolderFeedID = parentFolder?.feedID {
if let parentFolderFeedID = parentFolder?.itemID {
self.treeControllerDelegate.addFilterException(parentFolderFeedID)
}
@@ -1184,7 +1184,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
}
func showFeedInspector() {
let timelineWebFeed = timelineFeed as? WebFeed
let timelineWebFeed = timelineFeed as? Feed
let articleFeed = currentArticle?.feed
guard let feed = timelineWebFeed ?? articleFeed else {
return
@@ -1192,7 +1192,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
showFeedInspector(for: feed)
}
func showFeedInspector(for feed: WebFeed) {
func showFeedInspector(for feed: Feed) {
let hosting = UIHostingController(rootView: InjectedNavigationView(injectedView: WebFeedInspectorView(webFeed: feed)))
@@ -1233,7 +1233,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
func homePageURLForFeed(_ indexPath: IndexPath) -> URL? {
guard let node = nodeFor(indexPath),
let feed = node.representedObject as? WebFeed,
let feed = node.representedObject as? Feed,
let homePageURL = feed.homePageURL,
let url = URL(string: homePageURL) else {
return nil
@@ -1487,15 +1487,15 @@ private extension SceneCoordinator {
}
func addToFilterExeptionsIfNecessary(_ feed: FeedProtocol?) {
if isReadFeedsFiltered, let feedID = feed?.feedID {
if isReadFeedsFiltered, let feedID = feed?.itemID {
if feed is SmartFeed {
treeControllerDelegate.addFilterException(feedID)
} else if let folderFeed = feed as? Folder {
if folderFeed.account?.existingFolder(withID: folderFeed.folderID) != nil {
treeControllerDelegate.addFilterException(feedID)
}
} else if let webFeed = feed as? WebFeed {
if webFeed.account?.existingFeed(withWebFeedID: webFeed.webFeedID) != nil {
} else if let webFeed = feed as? Feed {
if webFeed.account?.existingFeed(withFeedID: webFeed.feedID) != nil {
treeControllerDelegate.addFilterException(feedID)
addParentFolderToFilterExceptions(webFeed)
}
@@ -1506,7 +1506,7 @@ private extension SceneCoordinator {
func addParentFolderToFilterExceptions(_ feed: FeedProtocol) {
guard let node = treeController.rootNode.descendantNodeRepresentingObject(feed as AnyObject),
let folder = node.parent?.representedObject as? Folder,
let folderFeedID = folder.feedID else {
let folderFeedID = folder.itemID else {
return
}
@@ -1516,7 +1516,7 @@ private extension SceneCoordinator {
func addShadowTableToFilterExceptions() {
for section in shadowTable {
for feedNode in section.feedNodes {
if let feed = feedNode.node.representedObject as? FeedProtocol, let feedID = feed.feedID {
if let feed = feedNode.node.representedObject as? FeedProtocol, let feedID = feed.itemID {
treeControllerDelegate.addFilterException(feedID)
}
}
@@ -1651,7 +1651,7 @@ private extension SceneCoordinator {
func shadowTableContains(_ feed: FeedProtocol) -> Bool {
for section in shadowTable {
for feedNode in section.feedNodes {
if let nodeFeed = feedNode.node.representedObject as? FeedProtocol, nodeFeed.feedID == feed.feedID {
if let nodeFeed = feedNode.node.representedObject as? FeedProtocol, nodeFeed.itemID == feed.itemID {
return true
}
}
@@ -1676,7 +1676,7 @@ private extension SceneCoordinator {
func updateShowNamesAndIcons() {
if timelineFeed is WebFeed {
if timelineFeed is Feed {
showFeedNames = {
for article in articles {
if !article.byline().isEmpty {
@@ -2016,7 +2016,7 @@ private extension SceneCoordinator {
if !unsortedArticleIDs.contains(article.articleID) {
updatedArticles.insert(article)
}
if article.account?.existingFeed(withWebFeedID: article.webFeedID) == nil {
if article.account?.existingFeed(withFeedID: article.feedID) == nil {
updatedArticles.remove(article)
}
}
@@ -2089,19 +2089,19 @@ private extension SceneCoordinator {
return false
}
func timelineFetcherContainsAnyFeed(_ feeds: Set<WebFeed>) -> Bool {
func timelineFetcherContainsAnyFeed(_ feeds: Set<Feed>) -> Bool {
// Return true if theres a match or if a folder contains (recursively) one of feeds
if let feed = timelineFeed as? WebFeed {
if let feed = timelineFeed as? Feed {
for oneFeed in feeds {
if feed.webFeedID == oneFeed.webFeedID || feed.url == oneFeed.url {
if feed.feedID == oneFeed.feedID || feed.url == oneFeed.url {
return true
}
}
} else if let folder = timelineFeed as? Folder {
for oneFeed in feeds {
if folder.hasFeed(with: oneFeed.webFeedID) || folder.hasFeed(withURL: oneFeed.url) {
if folder.hasFeed(with: oneFeed.feedID) || folder.hasFeed(withURL: oneFeed.url) {
return true
}
}
@@ -2172,10 +2172,10 @@ private extension SceneCoordinator {
}
})
case .webFeed(let accountID, let webFeedID):
case .feed(let accountID, let webFeedID):
guard let accountNode = findAccountNode(accountID: accountID),
let account = accountNode.representedObject as? Account,
let webFeed = account.existingFeed(withWebFeedID: webFeedID) else {
let webFeed = account.existingFeed(withFeedID: webFeedID) else {
return
}
@@ -2204,7 +2204,7 @@ private extension SceneCoordinator {
return
}
guard let webFeed = account.existingFeed(withWebFeedID: webFeedID) else {
guard let webFeed = account.existingFeed(withFeedID: webFeedID) else {
return
}
@@ -2233,7 +2233,7 @@ private extension SceneCoordinator {
}
return found
case .webFeed:
case .feed:
let found = selectFeedAndArticle(itemIdentifier: itemIdentifier, articleID: articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY)
if found {
treeControllerDelegate.addFilterException(itemIdentifier)
@@ -2267,7 +2267,7 @@ private extension SceneCoordinator {
}
func findWebFeedNode(webFeedID: String, beginningAt startingNode: Node) -> Node? {
if let node = startingNode.descendantNode(where: { ($0.representedObject as? WebFeed)?.webFeedID == webFeedID }) {
if let node = startingNode.descendantNode(where: { ($0.representedObject as? Feed)?.feedID == webFeedID }) {
return node
}
return nil

View File

@@ -18,9 +18,9 @@ struct NewArticleNotificationsView: View, Logging {
var body: some View {
List(activeAccounts, id: \.accountID) { account in
Section(header: Text(account.nameForDisplay)) {
ForEach(sortedWebFeedsForAccount(account), id: \.webFeedID) { feed in
ForEach(sortedWebFeedsForAccount(account), id: \.feedID) { feed in
WebFeedToggle(webfeed: feed)
.id(feed.webFeedID)
.id(feed.feedID)
}
}
.navigationTitle(Text("navigation.title.new-article-notifications", comment: "New Article Notifications"))
@@ -44,12 +44,12 @@ struct NewArticleNotificationsView: View, Logging {
}
})
.onReceive(NotificationCenter.default.publisher(for: .WebFeedIconDidBecomeAvailable), perform: { notification in
guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? WebFeed else { return }
guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? Feed else { return }
webFeed.objectWillChange.send()
})
}
private func sortedWebFeedsForAccount(_ account: Account) -> [WebFeed] {
private func sortedWebFeedsForAccount(_ account: Account) -> [Feed] {
return Array(account.flattenedFeeds()).sorted(by: { $0.nameForDisplay.caseInsensitiveCompare($1.nameForDisplay) == .orderedAscending })
}
@@ -58,7 +58,7 @@ struct NewArticleNotificationsView: View, Logging {
fileprivate struct WebFeedToggle: View {
@ObservedObject var webfeed: WebFeed
@ObservedObject var webfeed: Feed
var body: some View {
Toggle(isOn: Binding(
@@ -67,7 +67,7 @@ fileprivate struct WebFeedToggle: View {
Label {
Text(webfeed.nameForDisplay)
} icon: {
Image(uiImage: IconImageCache.shared.imageFor(webfeed.feedID!)!.image)
Image(uiImage: IconImageCache.shared.imageFor(webfeed.itemID!)!.image)
.resizable()
.frame(width: 25, height: 25)
.cornerRadius(4)