diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 1910a0ab1..98072ea84 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -1217,7 +1217,7 @@ private extension Account { // The unread number should match the feed’s unread count. let feedUnreadCount = articles.reduce(0) { (result, article) -> Int in - if article.webFeed == webFeed && !article.status.read { + if article.feed == webFeed && !article.status.read { return result + 1 } return result @@ -1281,7 +1281,7 @@ private extension Account { } func noteStatusesForArticlesDidChange(_ articles: Set
) { - let feeds = Set(articles.compactMap { $0.webFeed }) + let feeds = Set(articles.compactMap { $0.feed }) let statuses = Set(articles.map { $0.status }) let articleIDs = Set(articles.map { $0.articleID }) @@ -1372,10 +1372,10 @@ private extension Account { var webFeeds = Set() if let newArticles = articleChanges.newArticles { - webFeeds.formUnion(Set(newArticles.compactMap { $0.webFeed })) + webFeeds.formUnion(Set(newArticles.compactMap { $0.feed })) } if let updatedArticles = articleChanges.updatedArticles { - webFeeds.formUnion(Set(updatedArticles.compactMap { $0.webFeed })) + webFeeds.formUnion(Set(updatedArticles.compactMap { $0.feed })) } var shouldSendNotification = false diff --git a/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift b/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift index 91cd788b9..22dd38823 100644 --- a/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift +++ b/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift @@ -166,7 +166,7 @@ private extension CloudKitArticlesZone { func makeStatusRecord(_ article: Article) -> CKRecord { let recordID = CKRecord.ID(recordName: statusID(article.articleID), zoneID: zoneID) let record = CKRecord(recordType: CloudKitArticleStatus.recordType, recordID: recordID) - if let webFeedExternalID = article.webFeed?.externalID { + if let webFeedExternalID = article.feed?.externalID { record[CloudKitArticleStatus.Fields.webFeedExternalID] = webFeedExternalID } record[CloudKitArticleStatus.Fields.read] = article.status.read ? "1" : "0" @@ -178,7 +178,7 @@ private extension CloudKitArticlesZone { let recordID = CKRecord.ID(recordName: statusID(statusUpdate.articleID), zoneID: zoneID) let record = CKRecord(recordType: CloudKitArticleStatus.recordType, recordID: recordID) - if let webFeedExternalID = statusUpdate.article?.webFeed?.externalID { + if let webFeedExternalID = statusUpdate.article?.feed?.externalID { record[CloudKitArticleStatus.Fields.webFeedExternalID] = webFeedExternalID } @@ -194,7 +194,7 @@ private extension CloudKitArticlesZone { let articleStatusRecordID = CKRecord.ID(recordName: statusID(article.articleID), zoneID: zoneID) record[CloudKitArticle.Fields.articleStatus] = CKRecord.Reference(recordID: articleStatusRecordID, action: .deleteSelf) - record[CloudKitArticle.Fields.webFeedURL] = article.webFeed?.url + record[CloudKitArticle.Fields.webFeedURL] = article.feed?.url record[CloudKitArticle.Fields.uniqueID] = article.uniqueID record[CloudKitArticle.Fields.title] = article.title record[CloudKitArticle.Fields.contentHTML] = article.contentHTML diff --git a/Account/Sources/Account/DataExtensions.swift b/Account/Sources/Account/DataExtensions.swift index 52cbc7ad9..7fa174815 100644 --- a/Account/Sources/Account/DataExtensions.swift +++ b/Account/Sources/Account/DataExtensions.swift @@ -56,7 +56,7 @@ public extension Article { return manager.existingAccount(with: accountID) } - var webFeed: WebFeed? { + var feed: WebFeed? { return account?.existingWebFeed(withWebFeedID: webFeedID) } } diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index e6527ef2c..9443464b3 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -576,7 +576,7 @@ enum TimelineSourceMode { } @objc func showArticleExtractorMenu(_ button: NSButton) { - guard oneSelectedArticle?.webFeed != nil else { + guard oneSelectedArticle?.feed != nil else { return } @@ -587,7 +587,7 @@ enum TimelineSourceMode { alwaysUseReaderViewItem.target = self alwaysUseReaderViewItem.action = #selector(alwaysUseReaderView) alwaysUseReaderViewItem.state = { - if oneSelectedArticle?.webFeed?.isArticleExtractorAlwaysOn ?? false { + if oneSelectedArticle?.feed?.isArticleExtractorAlwaysOn ?? false { return NSControl.StateValue.on } else { return NSControl.StateValue.off @@ -600,7 +600,7 @@ enum TimelineSourceMode { } @objc func alwaysUseReaderView() { - guard let feed = oneSelectedArticle?.webFeed else { + guard let feed = oneSelectedArticle?.feed else { return } @@ -689,7 +689,7 @@ extension MainWindowController: TimelineContainerViewControllerDelegate { if let articles = articles { if articles.count == 1 { activityManager.reading(feed: nil, article: articles.first) - if articles.first?.webFeed?.isArticleExtractorAlwaysOn ?? false { + if articles.first?.feed?.isArticleExtractorAlwaysOn ?? false { detailState = .loading startArticleExtractorForCurrentLink() } else { @@ -1191,7 +1191,7 @@ private extension MainWindowController { return currentLink != nil } - if currentTimelineViewController?.selectedArticles.first?.webFeed != nil { + if currentTimelineViewController?.selectedArticles.first?.feed != nil { toolbarButton.isEnabled = true } diff --git a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift index 4dd5b80d5..2ff38e135 100644 --- a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift +++ b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift @@ -96,7 +96,7 @@ private extension ArticlePasteboardWriter { s += "Date: \(article.logicalDatePublished)\n\n" - if let feed = article.webFeed { + if let feed = article.feed { s += "Feed: \(feed.nameForDisplay)\n" if let homePageURL = feed.homePageURL { s += "Home page: \(homePageURL)\n" @@ -143,7 +143,7 @@ private extension ArticlePasteboardWriter { d[Key.articleID] = article.articleID d[Key.uniqueID] = article.uniqueID - if let feed = article.webFeed { + if let feed = article.feed { d[Key.feedURL] = feed.url } diff --git a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift index bdd1879a7..4828d3006 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift @@ -178,7 +178,7 @@ private extension TimelineViewController { menu.addSeparatorIfNeeded() - if articles.count == 1, let feed = articles.first!.webFeed { + if articles.count == 1, let feed = articles.first!.feed { if !(representedObjects?.contains(where: { $0 as? WebFeed == feed }) ?? false) { menu.addItem(selectFeedInSidebarMenuItem(feed)) } diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index 7e597be10..85f53298c 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -657,7 +657,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr guard let article = articles.articleAtRow(row) else { return false } - return feed == article.webFeed + return feed == article.feed } if let indexesToReload = indexesToReload { reloadCells(for: indexesToReload) @@ -962,7 +962,7 @@ extension TimelineViewController: NSTableViewDelegate { private func configureTimelineCell(_ cell: TimelineTableCellView, article: Article) { cell.objectValue = article let iconImage = article.iconImage() - cell.cellData = TimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.webFeed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcons, featuredImage: nil) + cell.cellData = TimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcons, featuredImage: nil) } private func iconFor(_ article: Article) -> IconImage? { diff --git a/Mac/Scriptability/Article+Scriptability.swift b/Mac/Scriptability/Article+Scriptability.swift index b76aec52f..094a023a3 100644 --- a/Mac/Scriptability/Article+Scriptability.swift +++ b/Mac/Scriptability/Article+Scriptability.swift @@ -143,7 +143,7 @@ class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectConta @objc(feed) var feed: ScriptableFeed? { - guard let parentFeed = self.article.webFeed, + guard let parentFeed = self.article.feed, let account = parentFeed.account else { return nil } diff --git a/Mac/Scriptability/NSApplication+Scriptability.swift b/Mac/Scriptability/NSApplication+Scriptability.swift index c97f0015f..6186a4228 100644 --- a/Mac/Scriptability/NSApplication+Scriptability.swift +++ b/Mac/Scriptability/NSApplication+Scriptability.swift @@ -30,7 +30,7 @@ extension NSApplication : ScriptingObjectContainer { func currentArticle() -> ScriptableArticle? { var scriptableArticle: ScriptableArticle? if let currentArticle = appDelegate.scriptingCurrentArticle { - if let feed = currentArticle.webFeed { + if let feed = currentArticle.feed { let scriptableFeed = ScriptableFeed(feed, container:self) scriptableArticle = ScriptableArticle(currentArticle, container:scriptableFeed) } @@ -42,7 +42,7 @@ extension NSApplication : ScriptingObjectContainer { func selectedArticles() -> NSArray { let articles = appDelegate.scriptingSelectedArticles let scriptableArticles:[ScriptableArticle] = articles.compactMap { article in - if let feed = article.webFeed { + if let feed = article.feed { let scriptableFeed = ScriptableFeed(feed, container:self) return ScriptableArticle(article, container:scriptableFeed) } else { diff --git a/Shared/Activity/ActivityManager.swift b/Shared/Activity/ActivityManager.swift index 4fb510307..8a8aa49a6 100644 --- a/Shared/Activity/ActivityManager.swift +++ b/Shared/Activity/ActivityManager.swift @@ -236,7 +236,7 @@ private extension ActivityManager { #endif func makeKeywords(_ article: Article) -> [String] { - let feedNameKeywords = makeKeywords(article.webFeed?.nameForDisplay) + let feedNameKeywords = makeKeywords(article.feed?.nameForDisplay) let articleTitleKeywords = makeKeywords(ArticleStringFormatter.truncatedTitle(article)) return feedNameKeywords + articleTitleKeywords } diff --git a/Shared/Article Rendering/ArticleRenderer.swift b/Shared/Article Rendering/ArticleRenderer.swift index b44bb2374..a207c1b14 100644 --- a/Shared/Article Rendering/ArticleRenderer.swift +++ b/Shared/Article Rendering/ArticleRenderer.swift @@ -241,8 +241,8 @@ private extension ArticleRenderer { d["dateline_style"] = "articleDateline" } - d["feed_link_title"] = article.webFeed?.nameForDisplay ?? "" - d["feed_link"] = article.webFeed?.homePageURL ?? "" + d["feed_link_title"] = article.feed?.nameForDisplay ?? "" + d["feed_link"] = article.feed?.homePageURL ?? "" d["byline"] = byline() @@ -261,7 +261,7 @@ private extension ArticleRenderer { } func byline() -> String { - guard let authors = article?.authors ?? article?.webFeed?.authors, !authors.isEmpty else { + guard let authors = article?.authors ?? article?.feed?.authors, !authors.isEmpty else { return "" } @@ -269,7 +269,7 @@ private extension ArticleRenderer { // This code assumes that multiple authors would never match the feed name so that // if there feed owner has an article co-author all authors are given the byline. if authors.count == 1, let author = authors.first { - if author.name == article?.webFeed?.nameForDisplay { + if author.name == article?.feed?.nameForDisplay { return "" } } @@ -333,10 +333,10 @@ private extension Article { var baseURL: URL? { var s = link if s == nil { - s = webFeed?.homePageURL + s = feed?.homePageURL } if s == nil { - s = webFeed?.url + s = feed?.url } guard let urlString = s else { diff --git a/Shared/ExtensionPoints/SendToMarsEditCommand.swift b/Shared/ExtensionPoints/SendToMarsEditCommand.swift index b86a661d1..89a867fff 100644 --- a/Shared/ExtensionPoints/SendToMarsEditCommand.swift +++ b/Shared/ExtensionPoints/SendToMarsEditCommand.swift @@ -50,7 +50,7 @@ private extension SendToMarsEditCommand { let body = article.contentHTML ?? article.contentText ?? article.summary let authorName = article.authors?.first?.name - let sender = SendToBlogEditorApp(targetDescriptor: targetDescriptor, title: article.title, body: body, summary: article.summary, link: article.externalLink, permalink: article.link, subject: nil, creator: authorName, commentsURL: nil, guid: article.uniqueID, sourceName: article.webFeed?.nameForDisplay, sourceHomeURL: article.webFeed?.homePageURL, sourceFeedURL: article.webFeed?.url) + let sender = SendToBlogEditorApp(targetDescriptor: targetDescriptor, title: article.title, body: body, summary: article.summary, link: article.externalLink, permalink: article.link, subject: nil, creator: authorName, commentsURL: nil, guid: article.uniqueID, sourceName: article.feed?.nameForDisplay, sourceHomeURL: article.feed?.homePageURL, sourceFeedURL: article.feed?.url) let _ = sender.send() } diff --git a/Shared/ExtensionPoints/SendToMicroBlogCommand.swift b/Shared/ExtensionPoints/SendToMicroBlogCommand.swift index bd5d000d2..f458138d8 100644 --- a/Shared/ExtensionPoints/SendToMicroBlogCommand.swift +++ b/Shared/ExtensionPoints/SendToMicroBlogCommand.swift @@ -65,10 +65,10 @@ private extension Article { // Feed name, or feed name + author name (if author is specified per-article). // Includes trailing space. - if let feedName = webFeed?.nameForDisplay, let authorName = authors?.first?.name { + if let feedName = feed?.nameForDisplay, let authorName = authors?.first?.name { return feedName + ", " + authorName + ": " } - if let feedName = webFeed?.nameForDisplay { + if let feedName = feed?.nameForDisplay { return feedName + ": " } return "" diff --git a/Shared/Extensions/ArticleUtilities.swift b/Shared/Extensions/ArticleUtilities.swift index 1f7b4e3f0..10c9da154 100644 --- a/Shared/Extensions/ArticleUtilities.swift +++ b/Shared/Extensions/ArticleUtilities.swift @@ -41,10 +41,6 @@ private func accountAndArticlesDictionary(_ articles: Set
) -> [String: extension Article { - var webFeed: WebFeed? { - return account?.existingWebFeed(withWebFeedID: webFeedID) - } - var url: URL? { return URL.encodingSpacesIfNeeded(rawLink) } @@ -138,7 +134,7 @@ extension Article { } func byline() -> String { - guard let authors = authors ?? webFeed?.authors, !authors.isEmpty else { + guard let authors = authors ?? feed?.authors, !authors.isEmpty else { return "" } @@ -146,7 +142,7 @@ extension Article { // This code assumes that multiple authors would never match the feed name so that // if there feed owner has an article co-author all authors are given the byline. if authors.count == 1, let author = authors.first { - if author.name == webFeed?.nameForDisplay { + if author.name == feed?.nameForDisplay { return "" } } @@ -214,7 +210,7 @@ extension Article { extension Article: SortableArticle { var sortableName: String { - return webFeed?.name ?? "" + return feed?.name ?? "" } var sortableDate: Date { diff --git a/Shared/IconImageCache.swift b/Shared/IconImageCache.swift index 5beb5c7aa..2add8f12d 100644 --- a/Shared/IconImageCache.swift +++ b/Shared/IconImageCache.swift @@ -52,7 +52,7 @@ class IconImageCache { if let iconImage = imageForAuthors(article.authors) { return iconImage } - guard let feed = article.webFeed else { + guard let feed = article.feed else { return nil } return imageForFeed(feed) diff --git a/Shared/UserNotifications/UserNotificationManager.swift b/Shared/UserNotifications/UserNotificationManager.swift index 231641caa..63bc5981e 100644 --- a/Shared/UserNotifications/UserNotificationManager.swift +++ b/Shared/UserNotifications/UserNotificationManager.swift @@ -26,7 +26,7 @@ final class UserNotificationManager: NSObject { } for article in articles { - if !article.status.read, let webFeed = article.webFeed, webFeed.isNotifyAboutNewArticles ?? false { + if !article.status.read, let webFeed = article.feed, webFeed.isNotifyAboutNewArticles ?? false { sendNotification(webFeed: webFeed, article: article) } } diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index f3761afcb..97c7b47b6 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -313,7 +313,7 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable, Loggi } private func configureArticleExtractorMenu() { - if let feed = article?.webFeed { + if let feed = article?.feed { let extractorOn = feed.isArticleExtractorAlwaysOn ?? false let readerAction = UIAction(title: NSLocalizedString("button.title.always-use-reader-view", comment: "Button title: Always Use Reader View"), image: AppAssets.articleExtractorOffSF, diff --git a/iOS/Article/ContextMenuPreviewViewController.swift b/iOS/Article/ContextMenuPreviewViewController.swift index 2d6e3e961..42598d8f8 100644 --- a/iOS/Article/ContextMenuPreviewViewController.swift +++ b/iOS/Article/ContextMenuPreviewViewController.swift @@ -21,7 +21,7 @@ import Articles override func viewDidLoad() { super.viewDidLoad() - blogNameLabel.text = article.webFeed?.nameForDisplay ?? "" + blogNameLabel.text = article.feed?.nameForDisplay ?? "" blogAuthorLabel.text = article.byline() articleTitleLabel.text = article.title ?? "" diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index 73bc0cd0f..7016abb6d 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -114,7 +114,7 @@ class WebViewController: UIViewController { if article != self.article { self.article = article if updateView { - if article?.webFeed?.isArticleExtractorAlwaysOn ?? false { + if article?.feed?.isArticleExtractorAlwaysOn ?? false { startArticleExtractor() } windowScrollY = 0 @@ -440,7 +440,7 @@ extension WebViewController: WKScriptMessageHandler { case MessageName.imageWasClicked: imageWasClicked(body: message.body as? String) case MessageName.showFeedInspector: - if let webFeed = article?.webFeed { + if let webFeed = article?.feed { coordinator.showFeedInspector(for: webFeed) } default: diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 63cd74021..23718cb39 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -480,7 +480,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner guard let article = dataSource.itemIdentifier(for: indexPath) else { return } - if article.webFeed == feed, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = iconImageFor(article) { + if article.feed == feed, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = iconImageFor(article) { cell.setIconImage(image) } } @@ -735,7 +735,7 @@ private extension MasterTimelineViewController { let showIcon = coordinator.showIcons && iconImage != nil let hideSeparater = indexPath.row == coordinator.articles.count - 1 - cell.cellData = MasterTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.webFeed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcon, featuredImage: featuredImage, numberOfLines: numberOfTextLines, iconSize: iconSize, hideSeparator: hideSeparater) + cell.cellData = MasterTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcon, featuredImage: featuredImage, numberOfLines: numberOfTextLines, iconSize: iconSize, hideSeparator: hideSeparater) } func iconImageFor(_ article: Article) -> IconImage? { @@ -898,7 +898,7 @@ private extension MasterTimelineViewController { } func discloseFeedAction(_ article: Article) -> UIAction? { - guard let webFeed = article.webFeed, + guard let webFeed = article.feed, !coordinator.timelineFeedIsEqualTo(webFeed) else { return nil } let title = NSLocalizedString("button.title.go-to-feed.titlecase", comment: "Go To Feed. Use to navigate to the user to the article list for a feed.") @@ -909,7 +909,7 @@ private extension MasterTimelineViewController { } func discloseFeedAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let webFeed = article.webFeed, + guard let webFeed = article.feed, !coordinator.timelineFeedIsEqualTo(webFeed) else { return nil } let title = NSLocalizedString("button.title.go-to-feed", comment: "Go To Feed. Use to navigate to the user to the article list for a feed.") @@ -921,7 +921,7 @@ private extension MasterTimelineViewController { } func markAllInFeedAsReadAction(_ article: Article, indexPath: IndexPath) -> UIAction? { - guard let webFeed = article.webFeed else { return nil } + guard let webFeed = article.feed else { return nil } guard let fetchedArticles = try? webFeed.fetchArticles() else { return nil } @@ -944,7 +944,7 @@ private extension MasterTimelineViewController { } func markAllInFeedAsReadAlertAction(_ article: Article, indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let webFeed = article.webFeed else { return nil } + guard let webFeed = article.feed else { return nil } guard let fetchedArticles = try? webFeed.fetchArticles() else { return nil } diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 4dd616d7d..aaf11aab7 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -1185,7 +1185,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner, Logging { func showFeedInspector() { let timelineWebFeed = timelineFeed as? WebFeed - let articleFeed = currentArticle?.webFeed + let articleFeed = currentArticle?.feed guard let feed = timelineWebFeed ?? articleFeed else { return }