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

@@ -54,7 +54,7 @@ class ActivityManager {
selectingActivity = makeSelectFeedActivity(feed: feed)
if let webFeed = feed as? WebFeed {
if let webFeed = feed as? Feed {
updateSelectingActivityFeedSearchAttributes(with: webFeed)
}
@@ -135,23 +135,23 @@ class ActivityManager {
CSSearchableIndex.default().deleteSearchableItems(withIdentifiers: ids)
}
static func cleanUp(_ webFeed: WebFeed) {
static func cleanUp(_ webFeed: Feed) {
CSSearchableIndex.default().deleteSearchableItems(withIdentifiers: identifiers(for: webFeed))
}
#endif
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
guard let webFeed = note.userInfo?[UserInfoKey.webFeed] as? WebFeed, let activityFeedId = selectingActivity?.userInfo?[ArticlePathKey.webFeedID] as? String else {
guard let webFeed = note.userInfo?[UserInfoKey.webFeed] as? Feed, let activityFeedId = selectingActivity?.userInfo?[ArticlePathKey.webFeedID] as? String else {
return
}
#if os(iOS)
if let article = readingArticle, activityFeedId == article.webFeedID {
if let article = readingArticle, activityFeedId == article.feedID {
updateReadArticleSearchAttributes(with: article)
}
#endif
if activityFeedId == webFeed.webFeedID {
if activityFeedId == webFeed.feedID {
updateSelectingActivityFeedSearchAttributes(with: webFeed)
}
}
@@ -181,7 +181,7 @@ private extension ActivityManager {
#if os(iOS)
activity.suggestedInvocationPhrase = title
activity.isEligibleForPrediction = true
activity.contentAttributeSet?.relatedUniqueIdentifier = feed.feedID?.description ?? ""
activity.contentAttributeSet?.relatedUniqueIdentifier = feed.itemID?.description ?? ""
#endif
return activity
@@ -245,7 +245,7 @@ private extension ActivityManager {
return value?.components(separatedBy: " ").filter { $0.count > 2 } ?? []
}
func updateSelectingActivityFeedSearchAttributes(with feed: WebFeed) {
func updateSelectingActivityFeedSearchAttributes(with feed: Feed) {
let attributeSet = CSSearchableItemAttributeSet(itemContentType: UTType.item.identifier)
attributeSet.title = feed.nameForDisplay
@@ -278,15 +278,15 @@ private extension ActivityManager {
return "account_\(folder.account!.accountID)_folder_\(folder.nameForDisplay)"
}
static func identifier(for feed: WebFeed) -> String {
return "account_\(feed.account!.accountID)_feed_\(feed.webFeedID)"
static func identifier(for feed: Feed) -> String {
return "account_\(feed.account!.accountID)_feed_\(feed.feedID)"
}
static func identifier(for article: Article) -> String {
return "account_\(article.accountID)_feed_\(article.feedID)_article_\(article.articleID)"
}
static func identifiers(for feed: WebFeed) -> [String] {
static func identifiers(for feed: Feed) -> [String] {
var ids = [String]()
ids.append(identifier(for: feed))
if let articles = try? feed.fetchArticles() {

View File

@@ -77,7 +77,7 @@ final class DeleteCommand: UndoableCommand {
}
for node in nodes {
if let _ = node.representedObject as? WebFeed {
if let _ = node.representedObject as? Feed {
continue
}
if let _ = node.representedObject as? Folder {
@@ -98,7 +98,7 @@ private struct SidebarItemSpecifier {
private weak var account: Account?
private let parentFolder: Folder?
private let folder: Folder?
private let webFeed: WebFeed?
private let webFeed: Feed?
private let path: ContainerPath
private let errorHandler: (Error) -> ()
@@ -118,7 +118,7 @@ private struct SidebarItemSpecifier {
self.parentFolder = node.parentFolder()
if let webFeed = node.representedObject as? WebFeed {
if let webFeed = node.representedObject as? Feed {
self.webFeed = webFeed
self.folder = nil
account = webFeed.account
@@ -271,7 +271,7 @@ private struct DeleteActionName {
var numberOfFolders = 0
for node in nodes {
if let _ = node.representedObject as? WebFeed {
if let _ = node.representedObject as? Feed {
numberOfFeeds += 1
}
else if let _ = node.representedObject as? Folder {

View File

@@ -116,11 +116,11 @@ extension Article {
return IconImageCache.shared.imageForArticle(self)
}
func iconImageUrl(webFeed: WebFeed) -> URL? {
func iconImageUrl(webFeed: Feed) -> URL? {
if let image = iconImage() {
let fm = FileManager.default
var path = fm.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let feedID = webFeed.webFeedID.replacingOccurrences(of: "/", with: "_")
let feedID = webFeed.feedID.replacingOccurrences(of: "/", with: "_")
#if os(macOS)
path.appendPathComponent(feedID + "_smallIcon.tiff")
#else

View File

@@ -25,7 +25,7 @@ extension Account: SmallIconProvider {
}
}
extension WebFeed: SmallIconProvider {
extension Feed: SmallIconProvider {
var smallIcon: IconImage? {
if let iconImage = appDelegate.faviconDownloader.favicon(for: self) {

View File

@@ -45,7 +45,7 @@ final class FaviconDownloader: Logging {
}
private let queue: DispatchQueue
private var cache = [WebFeed: IconImage]() // faviconURL: RSImage
private var cache = [Feed: IconImage]() // faviconURL: RSImage
struct UserInfoKey {
static let faviconURL = "faviconURL"
@@ -70,10 +70,10 @@ final class FaviconDownloader: Logging {
// MARK: - API
func resetCache() {
cache = [WebFeed: IconImage]()
cache = [Feed: IconImage]()
}
func favicon(for webFeed: WebFeed) -> IconImage? {
func favicon(for webFeed: Feed) -> IconImage? {
assert(Thread.isMainThread)
@@ -95,7 +95,7 @@ final class FaviconDownloader: Logging {
return nil
}
func faviconAsIcon(for webFeed: WebFeed) -> IconImage? {
func faviconAsIcon(for webFeed: Feed) -> IconImage? {
if let image = cache[webFeed] {
return image

View File

@@ -14,7 +14,7 @@ final class FaviconGenerator {
private static var faviconGeneratorCache = [String: IconImage]() // feedURL: RSImage
static func favicon(_ webFeed: WebFeed) -> IconImage {
static func favicon(_ webFeed: Feed) -> IconImage {
if let favicon = FaviconGenerator.faviconGeneratorCache[webFeed.url] {
return favicon

View File

@@ -38,7 +38,7 @@ class IconImageCache {
if let smartFeed = feed as? PseudoFeed {
return imageForSmartFeed(smartFeed, itemID)
}
if let webFeed = feed as? WebFeed, let iconImage = imageForWebFeed(webFeed, itemID) {
if let webFeed = feed as? Feed, let iconImage = imageForWebFeed(webFeed, itemID) {
return iconImage
}
if let smallIconProvider = feed as? SmallIconProvider {
@@ -80,7 +80,7 @@ private extension IconImageCache {
return nil
}
func imageForWebFeed(_ webFeed: WebFeed, _ itemID: ItemIdentifier) -> IconImage? {
func imageForWebFeed(_ webFeed: Feed, _ itemID: ItemIdentifier) -> IconImage? {
if let iconImage = webFeedIconImageCache[itemID] {
return iconImage
}

View File

@@ -53,8 +53,8 @@ public final class WebFeedIconDownloader {
}()
private var urlsInProgress = Set<String>()
private var cache = [WebFeed: IconImage]()
private var waitingForFeedURLs = [String: WebFeed]()
private var cache = [Feed: IconImage]()
private var waitingForFeedURLs = [String: Feed]()
init(imageDownloader: ImageDownloader, folder: String) {
self.imageDownloader = imageDownloader
@@ -68,10 +68,10 @@ public final class WebFeedIconDownloader {
}
func resetCache() {
cache = [WebFeed: IconImage]()
cache = [Feed: IconImage]()
}
func icon(for feed: WebFeed) -> IconImage? {
func icon(for feed: Feed) -> IconImage? {
if let cachedImage = cache[feed] {
return cachedImage
@@ -153,7 +153,7 @@ public final class WebFeedIconDownloader {
private extension WebFeedIconDownloader {
func icon(forHomePageURL homePageURL: String, feed: WebFeed, _ imageResultBlock: @escaping (RSImage?) -> Void) {
func icon(forHomePageURL homePageURL: String, feed: Feed, _ imageResultBlock: @escaping (RSImage?) -> Void) {
if homePagesWithNoIconURLCache.contains(homePageURL) || homePagesWithUglyIcons.contains(homePageURL) {
imageResultBlock(nil)
@@ -168,7 +168,7 @@ private extension WebFeedIconDownloader {
findIconURLForHomePageURL(homePageURL, feed: feed)
}
func icon(forURL url: String, feed: WebFeed, _ imageResultBlock: @escaping (RSImage?) -> Void) {
func icon(forURL url: String, feed: Feed, _ imageResultBlock: @escaping (RSImage?) -> Void) {
waitingForFeedURLs[url] = feed
guard let imageData = imageDownloader.image(for: url) else {
imageResultBlock(nil)
@@ -177,7 +177,7 @@ private extension WebFeedIconDownloader {
RSImage.scaledForIcon(imageData, imageResultBlock: imageResultBlock)
}
func postFeedIconDidBecomeAvailableNotification(_ feed: WebFeed) {
func postFeedIconDidBecomeAvailableNotification(_ feed: Feed) {
DispatchQueue.main.async {
let userInfo: [AnyHashable: Any] = [UserInfoKey.webFeed: feed]
@@ -197,7 +197,7 @@ private extension WebFeedIconDownloader {
homePageToIconURLCacheDirty = true
}
func findIconURLForHomePageURL(_ homePageURL: String, feed: WebFeed) {
func findIconURLForHomePageURL(_ homePageURL: String, feed: Feed) {
guard !urlsInProgress.contains(homePageURL) else {
return
@@ -214,7 +214,7 @@ private extension WebFeedIconDownloader {
}
}
func pullIconURL(from metadata: RSHTMLMetadata, homePageURL: String, feed: WebFeed) {
func pullIconURL(from metadata: RSHTMLMetadata, homePageURL: String, feed: Feed) {
if let url = metadata.bestWebsiteIconURL() {
cacheIconURL(for: homePageURL, url)

View File

@@ -100,7 +100,7 @@ private extension FeedTreeControllerDelegate {
}
func createNode(representedObject: Any, parent: Node) -> Node? {
if let webFeed = representedObject as? WebFeed {
if let webFeed = representedObject as? Feed {
return createNode(webFeed: webFeed, parent: parent)
}
@@ -115,7 +115,7 @@ private extension FeedTreeControllerDelegate {
return nil
}
func createNode(webFeed: WebFeed, parent: Node) -> Node {
func createNode(webFeed: Feed, parent: Node) -> Node {
return parent.createChildNode(webFeed)
}

View File

@@ -53,7 +53,7 @@ final class UserNotificationManager: NSObject {
private extension UserNotificationManager {
func sendNotification(webFeed: WebFeed, article: Article) {
func sendNotification(webFeed: Feed, article: Article) {
let content = UNMutableNotificationContent()
content.title = webFeed.nameForDisplay
@@ -61,7 +61,7 @@ private extension UserNotificationManager {
content.subtitle = ArticleStringFormatter.truncatedTitle(article)
}
content.body = ArticleStringFormatter.truncatedSummary(article)
content.threadIdentifier = webFeed.webFeedID
content.threadIdentifier = webFeed.feedID
content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: AppAssets.notificationSoundBlipFileName))
content.userInfo = [UserInfoKey.articlePath: article.pathUserInfo]
content.categoryIdentifier = "NEW_ARTICLE_NOTIFICATION_CATEGORY"
@@ -79,9 +79,9 @@ private extension UserNotificationManager {
/// - webFeed: `WebFeed`
/// - Returns: A `UNNotifcationAttachment` if an icon is available. Otherwise nil.
/// - Warning: In certain scenarios, this will return the `faviconTemplateImage`.
func thumbnailAttachment(for article: Article, webFeed: WebFeed) -> UNNotificationAttachment? {
func thumbnailAttachment(for article: Article, webFeed: Feed) -> UNNotificationAttachment? {
if let imageURL = article.iconImageUrl(webFeed: webFeed) {
let thumbnail = try? UNNotificationAttachment(identifier: webFeed.webFeedID, url: imageURL, options: nil)
let thumbnail = try? UNNotificationAttachment(identifier: webFeed.feedID, url: imageURL, options: nil)
return thumbnail
}
return nil