Rename Article.webFeed to Article.feed.

This commit is contained in:
Brent Simmons
2023-07-02 16:22:14 -07:00
parent bb450ababa
commit 75f1eee00c
21 changed files with 47 additions and 51 deletions

View File

@@ -1217,7 +1217,7 @@ private extension Account {
// The unread number should match the feeds 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<Article>) {
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<WebFeed>()
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

View File

@@ -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

View File

@@ -56,7 +56,7 @@ public extension Article {
return manager.existingAccount(with: accountID)
}
var webFeed: WebFeed? {
var feed: WebFeed? {
return account?.existingWebFeed(withWebFeedID: webFeedID)
}
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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))
}

View File

@@ -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? {

View File

@@ -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 }

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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()
}

View File

@@ -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 ""

View File

@@ -41,10 +41,6 @@ private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [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 {

View File

@@ -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)

View File

@@ -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)
}
}

View File

@@ -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,

View File

@@ -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 ?? ""

View File

@@ -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:

View File

@@ -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
}

View File

@@ -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
}