Rename WebFeed to Feed.

This commit is contained in:
Brent Simmons 2024-02-25 21:41:18 -08:00
parent b25c9eae94
commit b705433270
48 changed files with 287 additions and 287 deletions

View File

@ -56,7 +56,7 @@ public enum FetchType {
case unread(_: Int? = nil)
case today(_: Int? = nil)
case folder(Folder, Bool)
case webFeed(WebFeed)
case webFeed(Feed)
case articleIDs(Set<String>)
case search(String)
case searchWithArticleIDs(String, Set<String>)
@ -142,7 +142,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
}
public var topLevelWebFeeds = Set<WebFeed>()
public var topLevelWebFeeds = Set<Feed>()
public var folders: Set<Folder>? = Set<Folder>()
public var externalID: String? {
@ -162,15 +162,15 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
private var webFeedDictionariesNeedUpdate = true
private var _idToWebFeedDictionary = [String: WebFeed]()
var idToWebFeedDictionary: [String: WebFeed] {
private var _idToWebFeedDictionary = [String: Feed]()
var idToWebFeedDictionary: [String: Feed] {
if webFeedDictionariesNeedUpdate {
rebuildWebFeedDictionaries()
}
return _idToWebFeedDictionary
}
private var _externalIDToWebFeedDictionary = [String: WebFeed]()
var externalIDToWebFeedDictionary: [String: WebFeed] {
private var _externalIDToWebFeedDictionary = [String: Feed]()
var externalIDToWebFeedDictionary: [String: Feed] {
if webFeedDictionariesNeedUpdate {
rebuildWebFeedDictionaries()
}
@ -213,7 +213,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
private var unreadCounts = [String: Int]() // [feedID: Int]
private var _flattenedWebFeeds = Set<WebFeed>()
private var _flattenedWebFeeds = Set<Feed>()
private var flattenedWebFeedsNeedUpdate = true
private lazy var opmlFile = OPMLFile(filename: (dataFolder as NSString).appendingPathComponent("Subscriptions.opml"), account: self)
@ -528,7 +528,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return existingFolder(withExternalID: externalID)
}
func existingContainers(withWebFeed webFeed: WebFeed) -> [Container] {
func existingContainers(withWebFeed webFeed: Feed) -> [Container] {
var containers = [Container]()
if topLevelWebFeeds.contains(webFeed) {
containers.append(self)
@ -579,10 +579,10 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return folders?.first(where: { $0.externalID == externalID })
}
func newWebFeed(with opmlFeedSpecifier: RSOPMLFeedSpecifier) -> WebFeed {
func newWebFeed(with opmlFeedSpecifier: RSOPMLFeedSpecifier) -> Feed {
let feedURL = opmlFeedSpecifier.feedURL
let metadata = webFeedMetadata(feedURL: feedURL, webFeedID: feedURL)
let feed = WebFeed(account: self, url: opmlFeedSpecifier.feedURL, metadata: metadata)
let feed = Feed(account: self, url: opmlFeedSpecifier.feedURL, metadata: metadata)
if let feedTitle = opmlFeedSpecifier.title {
if feed.name == nil {
feed.name = feedTitle
@ -591,35 +591,35 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return feed
}
public func addWebFeed(_ feed: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
public func addWebFeed(_ feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.addWebFeed(for: self, with: feed, to: container, completion: completion)
}
public func createWebFeed(url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void) {
public func createWebFeed(url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
delegate.createWebFeed(for: self, url: url, name: name, container: container, validateFeed: validateFeed, completion: completion)
}
func createWebFeed(with name: String?, url: String, webFeedID: String, homePageURL: String?) -> WebFeed {
func createWebFeed(with name: String?, url: String, webFeedID: String, homePageURL: String?) -> Feed {
let metadata = webFeedMetadata(feedURL: url, webFeedID: webFeedID)
let feed = WebFeed(account: self, url: url, metadata: metadata)
let feed = Feed(account: self, url: url, metadata: metadata)
feed.name = name
feed.homePageURL = homePageURL
return feed
}
public func removeWebFeed(_ feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
public func removeWebFeed(_ feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.removeWebFeed(for: self, with: feed, from: container, completion: completion)
}
public func moveWebFeed(_ feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
public func moveWebFeed(_ feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.moveWebFeed(for: self, with: feed, from: from, to: to, completion: completion)
}
public func renameWebFeed(_ feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
public func renameWebFeed(_ feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.renameWebFeed(for: self, with: feed, to: name, completion: completion)
}
public func restoreWebFeed(_ feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
public func restoreWebFeed(_ feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.restoreWebFeed(for: self, feed: feed, container: container, completion: completion)
}
@ -639,7 +639,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
delegate.restoreFolder(for: self, folder: folder, completion: completion)
}
func clearWebFeedMetadata(_ feed: WebFeed) {
func clearWebFeedMetadata(_ feed: Feed) {
webFeedMetadata[feed.url] = nil
}
@ -649,7 +649,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
structureDidChange()
}
public func updateUnreadCounts(for webFeeds: Set<WebFeed>, completion: VoidCompletionBlock? = nil) {
public func updateUnreadCounts(for webFeeds: Set<Feed>, completion: VoidCompletionBlock? = nil) {
fetchUnreadCounts(for: webFeeds, completion: completion)
}
@ -724,11 +724,11 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
database.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(completion)
}
public func unreadCount(for webFeed: WebFeed) -> Int {
public func unreadCount(for webFeed: Feed) -> Int {
return unreadCounts[webFeed.webFeedID] ?? 0
}
public func setUnreadCount(_ unreadCount: Int, for webFeed: WebFeed) {
public func setUnreadCount(_ unreadCount: Int, for webFeed: Feed) {
unreadCounts[webFeed.webFeedID] = unreadCount
}
@ -740,7 +740,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
webFeedDictionariesNeedUpdate = true
}
func update(_ webFeed: WebFeed, with parsedFeed: ParsedFeed, _ completion: @escaping UpdateArticlesCompletionBlock) {
func update(_ webFeed: Feed, with parsedFeed: ParsedFeed, _ completion: @escaping UpdateArticlesCompletionBlock) {
// Used only by an On My Mac or iCloud account.
precondition(Thread.isMainThread)
precondition(type == .onMyMac || type == .cloudKit)
@ -888,7 +888,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
// MARK: - Container
public func flattenedWebFeeds() -> Set<WebFeed> {
public func flattenedWebFeeds() -> Set<Feed> {
assert(Thread.isMainThread)
if flattenedWebFeedsNeedUpdate {
updateFlattenedWebFeeds()
@ -896,13 +896,13 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return _flattenedWebFeeds
}
public func removeWebFeed(_ webFeed: WebFeed) {
public func removeWebFeed(_ webFeed: Feed) {
topLevelWebFeeds.remove(webFeed)
structureDidChange()
postChildrenDidChangeNotification()
}
public func removeFeeds(_ webFeeds: Set<WebFeed>) {
public func removeFeeds(_ webFeeds: Set<Feed>) {
guard !webFeeds.isEmpty else {
return
}
@ -911,13 +911,13 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
postChildrenDidChangeNotification()
}
public func addWebFeed(_ webFeed: WebFeed) {
public func addWebFeed(_ webFeed: Feed) {
topLevelWebFeeds.insert(webFeed)
structureDidChange()
postChildrenDidChangeNotification()
}
func addFeedIfNotInAnyFolder(_ webFeed: WebFeed) {
func addFeedIfNotInAnyFolder(_ webFeed: Feed) {
if !flattenedWebFeeds().contains(webFeed) {
addWebFeed(webFeed)
}
@ -959,7 +959,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
@objc func unreadCountDidChange(_ note: Notification) {
if let feed = note.object as? WebFeed, feed.account === self {
if let feed = note.object as? Feed, feed.account === self {
updateUnreadCount()
}
}
@ -1067,13 +1067,13 @@ private extension Account {
fetchUnreadArticlesAsync(forContainer: folder, limit: nil, completion)
}
func fetchArticles(webFeed: WebFeed) throws -> Set<Article> {
func fetchArticles(webFeed: Feed) throws -> Set<Article> {
let articles = try database.fetchArticles(webFeed.webFeedID)
validateUnreadCount(webFeed, articles)
return articles
}
func fetchArticlesAsync(webFeed: WebFeed, _ completion: @escaping ArticleSetResultBlock) {
func fetchArticlesAsync(webFeed: Feed, _ completion: @escaping ArticleSetResultBlock) {
database.fetchArticlesAsync(webFeed.webFeedID) { [weak self] articleSetResult in
switch articleSetResult {
case .success(let articles):
@ -1109,7 +1109,7 @@ private extension Account {
return database.fetchArticlesAsync(articleIDs: articleIDs, completion)
}
func fetchUnreadArticles(webFeed: WebFeed) throws -> Set<Article> {
func fetchUnreadArticles(webFeed: Feed) throws -> Set<Article> {
let articles = try database.fetchUnreadArticles(Set([webFeed.webFeedID]), nil)
validateUnreadCount(webFeed, articles)
return articles
@ -1167,7 +1167,7 @@ private extension Account {
}
}
func validateUnreadCountsAfterFetchingUnreadArticles(_ webFeeds: Set<WebFeed>, _ articles: Set<Article>) {
func validateUnreadCountsAfterFetchingUnreadArticles(_ webFeeds: Set<Feed>, _ articles: Set<Article>) {
// Validate unread counts. This was the site of a performance slowdown:
// it was calling going through the entire list of articles once per feed:
// feeds.forEach { validateUnreadCount($0, articles) }
@ -1183,7 +1183,7 @@ private extension Account {
}
}
func validateUnreadCount(_ webFeed: WebFeed, _ articles: Set<Article>) {
func validateUnreadCount(_ webFeed: Feed, _ articles: Set<Article>) {
// articles must contain all the unread articles for the feed.
// The unread number should match the feeds unread count.
@ -1214,7 +1214,7 @@ private extension Account {
}
func updateFlattenedWebFeeds() {
var feeds = Set<WebFeed>()
var feeds = Set<Feed>()
feeds.formUnion(topLevelWebFeeds)
for folder in folders! {
feeds.formUnion(folder.flattenedWebFeeds())
@ -1225,8 +1225,8 @@ private extension Account {
}
func rebuildWebFeedDictionaries() {
var idDictionary = [String: WebFeed]()
var externalIDDictionary = [String: WebFeed]()
var idDictionary = [String: Feed]()
var externalIDDictionary = [String: Feed]()
flattenedWebFeeds().forEach { (feed) in
idDictionary[feed.webFeedID] = feed
@ -1276,7 +1276,7 @@ private extension Account {
/// Fetch unread counts for zero or more feeds.
///
/// Uses the most efficient method based on how many feeds were passed in.
func fetchUnreadCounts(for feeds: Set<WebFeed>, completion: VoidCompletionBlock?) {
func fetchUnreadCounts(for feeds: Set<Feed>, completion: VoidCompletionBlock?) {
if feeds.isEmpty {
completion?()
return
@ -1292,7 +1292,7 @@ private extension Account {
}
}
func fetchUnreadCount(_ feed: WebFeed, _ completion: VoidCompletionBlock?) {
func fetchUnreadCount(_ feed: Feed, _ completion: VoidCompletionBlock?) {
database.fetchUnreadCount(feed.webFeedID) { result in
if let unreadCount = try? result.get() {
feed.unreadCount = unreadCount
@ -1301,7 +1301,7 @@ private extension Account {
}
}
func fetchUnreadCounts(_ feeds: Set<WebFeed>, _ completion: VoidCompletionBlock?) {
func fetchUnreadCounts(_ feeds: Set<Feed>, _ completion: VoidCompletionBlock?) {
let webFeedIDs = Set(feeds.map { $0.webFeedID })
database.fetchUnreadCounts(for: webFeedIDs) { result in
if let unreadCountDictionary = try? result.get() {
@ -1331,7 +1331,7 @@ private extension Account {
}
}
func processUnreadCounts(unreadCountDictionary: UnreadCountDictionary, feeds: Set<WebFeed>) {
func processUnreadCounts(unreadCountDictionary: UnreadCountDictionary, feeds: Set<Feed>) {
for feed in feeds {
// When the unread count is zero, it wont appear in unreadCountDictionary.
let unreadCount = unreadCountDictionary[feed.webFeedID] ?? 0
@ -1340,7 +1340,7 @@ private extension Account {
}
func sendNotificationAbout(_ articleChanges: ArticleChanges) {
var webFeeds = Set<WebFeed>()
var webFeeds = Set<Feed>()
if let newArticles = articleChanges.newArticles {
webFeeds.formUnion(Set(newArticles.compactMap { $0.webFeed }))
@ -1383,11 +1383,11 @@ private extension Account {
extension Account {
public func existingWebFeed(withWebFeedID webFeedID: String) -> WebFeed? {
public func existingWebFeed(withWebFeedID webFeedID: String) -> Feed? {
return idToWebFeedDictionary[webFeedID]
}
public func existingWebFeed(withExternalID externalID: String) -> WebFeed? {
public func existingWebFeed(withExternalID externalID: String) -> Feed? {
return externalIDToWebFeedDictionary[externalID]
}

View File

@ -36,13 +36,13 @@ protocol AccountDelegate {
func renameFolder(for account: Account, with folder: Folder, to name: String, completion: @escaping (Result<Void, Error>) -> Void)
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void)
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void)
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> Void)
func addWebFeed(for account: Account, with: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func removeWebFeed(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void)
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void)
func renameWebFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void)
func addWebFeed(for account: Account, with: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func removeWebFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func moveWebFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void)
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func restoreWebFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void)
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool, completion: @escaping (Result<Void, Error>) -> Void)

View File

@ -18,7 +18,7 @@ public protocol ArticleFetcher {
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock)
}
extension WebFeed: ArticleFetcher {
extension Feed: ArticleFetcher {
public func fetchArticles() throws -> Set<Article> {
return try account?.fetchArticles(.webFeed(self)) ?? Set<Article>()

View File

@ -175,7 +175,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
func createWebFeed(for account: Account, url urlString: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createWebFeed(for account: Account, url urlString: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
guard let url = URL(string: urlString) else {
completion(.failure(LocalAccountDelegateError.invalidParameter))
return
@ -186,7 +186,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
createRSSWebFeed(for: account, url: url, editedName: editedName, container: container, validateFeed: validateFeed, completion: completion)
}
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
func renameWebFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
let editedName = name.isEmpty ? nil : name
refreshProgress.addToNumberOfTasksAndRemaining(1)
accountZone.renameWebFeed(feed, editedName: editedName) { result in
@ -202,7 +202,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
}
func removeWebFeed(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func removeWebFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
removeWebFeedFromCloud(for: account, with: feed, from: container) { result in
switch result {
case .success:
@ -222,7 +222,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
}
func moveWebFeed(for account: Account, with feed: WebFeed, from fromContainer: Container, to toContainer: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func moveWebFeed(for account: Account, with feed: Feed, from fromContainer: Container, to toContainer: Container, completion: @escaping (Result<Void, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
accountZone.moveWebFeed(feed, from: fromContainer, to: toContainer) { result in
self.refreshProgress.completeTask()
@ -238,7 +238,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
}
func addWebFeed(for account: Account, with feed: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func addWebFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
accountZone.addWebFeed(feed, to: container) { result in
self.refreshProgress.completeTask()
@ -253,7 +253,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
}
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func restoreWebFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
createWebFeed(for: account, url: feed.url, name: feed.editedName, container: container, validateFeed: true) { result in
switch result {
case .success:
@ -562,7 +562,7 @@ private extension CloudKitAccountDelegate {
}
func combinedRefresh(_ account: Account, _ webFeeds: Set<WebFeed>, completion: @escaping (Result<Void, Error>) -> Void) {
func combinedRefresh(_ account: Account, _ webFeeds: Set<Feed>, completion: @escaping (Result<Void, Error>) -> Void) {
let group = DispatchGroup()
@ -576,7 +576,7 @@ private extension CloudKitAccountDelegate {
}
}
func createRSSWebFeed(for account: Account, url: URL, editedName: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createRSSWebFeed(for account: Account, url: URL, editedName: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
func addDeadFeed() {
let feed = account.createWebFeed(with: editedName, url: url.absoluteString, webFeedID: url.absoluteString, homePageURL: nil)
@ -683,7 +683,7 @@ private extension CloudKitAccountDelegate {
}
}
func sendNewArticlesToTheCloud(_ account: Account, _ feed: WebFeed) {
func sendNewArticlesToTheCloud(_ account: Account, _ feed: Feed) {
account.fetchArticlesAsync(.webFeed(feed)) { result in
switch result {
case .success(let articles):
@ -771,7 +771,7 @@ private extension CloudKitAccountDelegate {
}
func removeWebFeedFromCloud(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func removeWebFeedFromCloud(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(2)
accountZone.removeWebFeed(feed, from: container) { result in
self.refreshProgress.completeTask()
@ -798,7 +798,7 @@ private extension CloudKitAccountDelegate {
extension CloudKitAccountDelegate: LocalAccountRefresherDelegate {
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: WebFeed) {
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: Feed) {
refreshProgress.completeTask()
}

View File

@ -119,7 +119,7 @@ final class CloudKitAccountZone: CloudKitZone {
}
/// Rename the given web feed
func renameWebFeed(_ webFeed: WebFeed, editedName: String?, completion: @escaping (Result<Void, Error>) -> Void) {
func renameWebFeed(_ webFeed: Feed, editedName: String?, completion: @escaping (Result<Void, Error>) -> Void) {
guard let externalID = webFeed.externalID else {
completion(.failure(CloudKitZoneError.corruptAccount))
return
@ -140,7 +140,7 @@ final class CloudKitAccountZone: CloudKitZone {
}
/// Removes a web feed from a container and optionally deletes it, calling the completion with true if deleted
func removeWebFeed(_ webFeed: WebFeed, from: Container, completion: @escaping (Result<Bool, Error>) -> Void) {
func removeWebFeed(_ webFeed: Feed, from: Container, completion: @escaping (Result<Bool, Error>) -> Void) {
guard let fromContainerExternalID = from.externalID else {
completion(.failure(CloudKitZoneError.corruptAccount))
return
@ -189,7 +189,7 @@ final class CloudKitAccountZone: CloudKitZone {
}
}
func moveWebFeed(_ webFeed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func moveWebFeed(_ webFeed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
guard let fromContainerExternalID = from.externalID, let toContainerExternalID = to.externalID else {
completion(.failure(CloudKitZoneError.corruptAccount))
return
@ -211,7 +211,7 @@ final class CloudKitAccountZone: CloudKitZone {
}
}
func addWebFeed(_ webFeed: WebFeed, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func addWebFeed(_ webFeed: Feed, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
guard let toContainerExternalID = to.externalID else {
completion(.failure(CloudKitZoneError.corruptAccount))
return

View File

@ -17,7 +17,7 @@ class CloudKitAcountZoneDelegate: CloudKitZoneDelegate {
private typealias UnclaimedWebFeed = (url: URL, name: String?, editedName: String?, homePageURL: String?, webFeedExternalID: String)
private var newUnclaimedWebFeeds = [String: [UnclaimedWebFeed]]()
private var existingUnclaimedWebFeeds = [String: [WebFeed]]()
private var existingUnclaimedWebFeeds = [String: [Feed]]()
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
@ -140,7 +140,7 @@ class CloudKitAcountZoneDelegate: CloudKitZoneDelegate {
private extension CloudKitAcountZoneDelegate {
func updateWebFeed(_ webFeed: WebFeed, name: String?, editedName: String?, homePageURL: String?, containerExternalIDs: [String]) {
func updateWebFeed(_ webFeed: Feed, name: String?, editedName: String?, homePageURL: String?, containerExternalIDs: [String]) {
guard let account = account else { return }
webFeed.name = name
@ -192,12 +192,12 @@ private extension CloudKitAcountZoneDelegate {
}
}
func addExistingUnclaimedWebFeed(_ webFeed: WebFeed, containerExternalID: String) {
func addExistingUnclaimedWebFeed(_ webFeed: Feed, containerExternalID: String) {
if var unclaimedWebFeeds = self.existingUnclaimedWebFeeds[containerExternalID] {
unclaimedWebFeeds.append(webFeed)
self.existingUnclaimedWebFeeds[containerExternalID] = unclaimedWebFeeds
} else {
var unclaimedWebFeeds = [WebFeed]()
var unclaimedWebFeeds = [Feed]()
unclaimedWebFeeds.append(webFeed)
self.existingUnclaimedWebFeeds[containerExternalID] = unclaimedWebFeeds
}

View File

@ -19,7 +19,7 @@ extension Notification.Name {
public protocol Container: AnyObject, ContainerIdentifiable {
var account: Account? { get }
var topLevelWebFeeds: Set<WebFeed> { get set }
var topLevelWebFeeds: Set<Feed> { get set }
var folders: Set<Folder>? { get set }
var externalID: String? { get set }
@ -29,17 +29,17 @@ public protocol Container: AnyObject, ContainerIdentifiable {
func hasChildFolder(with: String) -> Bool
func childFolder(with: String) -> Folder?
func removeWebFeed(_ webFeed: WebFeed)
func addWebFeed(_ webFeed: WebFeed)
func removeWebFeed(_ webFeed: Feed)
func addWebFeed(_ webFeed: Feed)
//Recursive  checks subfolders
func flattenedWebFeeds() -> Set<WebFeed>
func has(_ webFeed: WebFeed) -> Bool
func flattenedWebFeeds() -> Set<Feed>
func has(_ webFeed: Feed) -> Bool
func hasWebFeed(with webFeedID: String) -> Bool
func hasWebFeed(withURL url: String) -> Bool
func existingWebFeed(withWebFeedID: String) -> WebFeed?
func existingWebFeed(withURL url: String) -> WebFeed?
func existingWebFeed(withExternalID externalID: String) -> WebFeed?
func existingWebFeed(withWebFeedID: String) -> Feed?
func existingWebFeed(withURL url: String) -> Feed?
func existingWebFeed(withExternalID externalID: String) -> Feed?
func existingFolder(with name: String) -> Folder?
func existingFolder(withID: Int) -> Folder?
@ -69,7 +69,7 @@ public extension Container {
}
func objectIsChild(_ object: AnyObject) -> Bool {
if let feed = object as? WebFeed {
if let feed = object as? Feed {
return topLevelWebFeeds.contains(feed)
}
if let folder = object as? Folder {
@ -78,8 +78,8 @@ public extension Container {
return false
}
func flattenedWebFeeds() -> Set<WebFeed> {
var feeds = Set<WebFeed>()
func flattenedWebFeeds() -> Set<Feed> {
var feeds = Set<Feed>()
feeds.formUnion(topLevelWebFeeds)
if let folders = folders {
for folder in folders {
@ -97,11 +97,11 @@ public extension Container {
return existingWebFeed(withURL: url) != nil
}
func has(_ webFeed: WebFeed) -> Bool {
func has(_ webFeed: Feed) -> Bool {
return flattenedWebFeeds().contains(webFeed)
}
func existingWebFeed(withWebFeedID webFeedID: String) -> WebFeed? {
func existingWebFeed(withWebFeedID webFeedID: String) -> Feed? {
for feed in flattenedWebFeeds() {
if feed.webFeedID == webFeedID {
return feed
@ -110,7 +110,7 @@ public extension Container {
return nil
}
func existingWebFeed(withURL url: String) -> WebFeed? {
func existingWebFeed(withURL url: String) -> Feed? {
for feed in flattenedWebFeeds() {
if feed.url == url {
return feed
@ -119,7 +119,7 @@ public extension Container {
return nil
}
func existingWebFeed(withExternalID externalID: String) -> WebFeed? {
func existingWebFeed(withExternalID externalID: String) -> Feed? {
for feed in flattenedWebFeeds() {
if feed.externalID == externalID {
return feed

View File

@ -14,7 +14,7 @@ public extension Notification.Name {
static let WebFeedSettingDidChange = Notification.Name(rawValue: "FeedSettingDidChangeNotification")
}
public extension WebFeed {
public extension Feed {
static let WebFeedSettingUserInfoKey = "feedSetting"
@ -30,7 +30,7 @@ public extension WebFeed {
}
}
extension WebFeed {
extension Feed {
func takeSettings(from parsedFeed: ParsedFeed) {
iconURL = parsedFeed.iconURL
@ -41,7 +41,7 @@ extension WebFeed {
}
func postFeedSettingDidChangeNotification(_ codingKey: WebFeedMetadata.CodingKeys) {
let userInfo = [WebFeed.WebFeedSettingUserInfoKey: codingKey.stringValue]
let userInfo = [Feed.WebFeedSettingUserInfoKey: codingKey.stringValue]
NotificationCenter.default.post(name: .WebFeedSettingDidChange, object: self, userInfo: userInfo)
}
}
@ -56,7 +56,7 @@ public extension Article {
return manager.existingAccount(with: accountID)
}
var webFeed: WebFeed? {
var webFeed: Feed? {
return account?.existingWebFeed(withWebFeedID: webFeedID)
}
}

View File

@ -11,7 +11,7 @@ import RSCore
import RSWeb
import Articles
public final class WebFeed: SidebarItem, Renamable, Hashable {
public final class Feed: SidebarItem, Renamable, Hashable {
public var defaultReadFilterType: ReadFilterType {
return .none
@ -269,14 +269,14 @@ public final class WebFeed: SidebarItem, Renamable, Hashable {
// MARK: - Equatable
public class func ==(lhs: WebFeed, rhs: WebFeed) -> Bool {
public class func ==(lhs: Feed, rhs: Feed) -> Bool {
return lhs.webFeedID == rhs.webFeedID && lhs.accountID == rhs.accountID
}
}
// MARK: - OPMLRepresentable
extension WebFeed: OPMLRepresentable {
extension Feed: OPMLRepresentable {
public func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String {
// https://github.com/brentsimmons/NetNewsWire/issues/527
@ -304,13 +304,13 @@ extension WebFeed: OPMLRepresentable {
}
}
extension Set where Element == WebFeed {
extension Set where Element == Feed {
func webFeedIDs() -> Set<String> {
return Set<String>(map { $0.webFeedID })
}
func sorted() -> Array<WebFeed> {
func sorted() -> Array<Feed> {
return sorted(by: { (webFeed1, webFeed2) -> Bool in
if webFeed1.nameForDisplay.localizedStandardCompare(webFeed2.nameForDisplay) == .orderedSame {
return webFeed1.url < webFeed2.url

View File

@ -388,7 +388,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.createSubscription(url: url) { result in
@ -420,7 +420,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
func renameWebFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
// This error should never happen
guard let subscriptionID = feed.externalID else {
@ -447,7 +447,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
func removeWebFeed(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func removeWebFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if feed.folderRelationship?.count ?? 0 > 1 {
deleteTagging(for: account, with: feed, from: container, completion: completion)
} else {
@ -455,7 +455,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
}
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func moveWebFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if from is Account {
addWebFeed(for: account, with: feed, to: to, completion: completion)
} else {
@ -470,7 +470,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
}
func addWebFeed(for account: Account, with feed: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func addWebFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if let folder = container as? Folder, let webFeedID = Int(feed.webFeedID) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
@ -502,7 +502,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func restoreWebFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if let existingFeed = account.existingWebFeed(withURL: feed.url) {
account.addWebFeed(existingFeed, to: container) { result in
@ -990,14 +990,14 @@ private extension FeedbinAccountDelegate {
}
}
func clearFolderRelationship(for feed: WebFeed, withFolderName folderName: String) {
func clearFolderRelationship(for feed: Feed, withFolderName folderName: String) {
if var folderRelationship = feed.folderRelationship {
folderRelationship[folderName] = nil
feed.folderRelationship = folderRelationship
}
}
func saveFolderRelationship(for feed: WebFeed, withFolderName folderName: String, id: String) {
func saveFolderRelationship(for feed: Feed, withFolderName folderName: String, id: String) {
if var folderRelationship = feed.folderRelationship {
folderRelationship[folderName] = id
feed.folderRelationship = folderRelationship
@ -1006,7 +1006,7 @@ private extension FeedbinAccountDelegate {
}
}
func decideBestFeedChoice(account: Account, url: String, name: String?, container: Container, choices: [FeedbinSubscriptionChoice], completion: @escaping (Result<WebFeed, Error>) -> Void) {
func decideBestFeedChoice(account: Account, url: String, name: String?, container: Container, choices: [FeedbinSubscriptionChoice], completion: @escaping (Result<Feed, Error>) -> Void) {
var orderFound = 0
let feedSpecifiers: [FeedSpecifier] = choices.map { choice in
@ -1025,7 +1025,7 @@ private extension FeedbinAccountDelegate {
}
}
func createFeed( account: Account, subscription sub: FeedbinSubscription, name: String?, container: Container, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createFeed( account: Account, subscription sub: FeedbinSubscription, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
DispatchQueue.main.async {
@ -1058,7 +1058,7 @@ private extension FeedbinAccountDelegate {
}
func initialFeedDownload( account: Account, feed: WebFeed, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func initialFeedDownload( account: Account, feed: Feed, completion: @escaping (Result<Feed, Error>) -> Void) {
// refreshArticles is being reused and will clear one of the tasks for us
refreshProgress.addToNumberOfTasksAndRemaining(4)
@ -1371,7 +1371,7 @@ private extension FeedbinAccountDelegate {
}
func deleteTagging(for account: Account, with feed: WebFeed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
func deleteTagging(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
if let folder = container as? Folder, let feedTaggingID = feed.folderRelationship?[folder.name ?? ""] {
refreshProgress.addToNumberOfTasksAndRemaining(1)
@ -1401,7 +1401,7 @@ private extension FeedbinAccountDelegate {
}
func deleteSubscription(for account: Account, with feed: WebFeed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
func deleteSubscription(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
// This error should never happen
guard let subscriptionID = feed.externalID else {

View File

@ -314,7 +314,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
}
}
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
do {
guard let credentials = credentials else {
@ -347,7 +347,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
}
}
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
func renameWebFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
let folderCollectionIds = account.folders?.filter { $0.has(feed) }.compactMap { $0.externalID }
guard let collectionIds = folderCollectionIds, let collectionId = collectionIds.first else {
completion(.failure(FeedlyAccountDelegateError.unableToRenameFeed(feed.nameForDisplay, name)))
@ -374,7 +374,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
feed.editedName = name
}
func addWebFeed(for account: Account, with feed: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func addWebFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
do {
guard let credentials = credentials else {
@ -405,7 +405,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
}
}
func removeWebFeed(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func removeWebFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
guard let folder = container as? Folder, let collectionId = folder.externalID else {
return DispatchQueue.main.async {
completion(.failure(FeedlyAccountDelegateError.unableToRemoveFeed(feed)))
@ -425,7 +425,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
folder.removeWebFeed(feed)
}
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func moveWebFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
guard let from = from as? Folder, let to = to as? Folder else {
return DispatchQueue.main.async {
completion(.failure(FeedlyAccountDelegateError.addFeedChooseFolder))
@ -458,7 +458,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
to.addWebFeed(feed)
}
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func restoreWebFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if let existingFeed = account.existingWebFeed(withURL: feed.url) {
account.addWebFeed(existingFeed, to: container) { result in
switch result {

View File

@ -14,11 +14,11 @@ enum FeedlyAccountDelegateError: LocalizedError {
case unableToAddFolder(String)
case unableToRenameFolder(String, String)
case unableToRemoveFolder(String)
case unableToMoveFeedBetweenFolders(WebFeed, Folder, Folder)
case unableToMoveFeedBetweenFolders(Feed, Folder, Folder)
case addFeedChooseFolder
case addFeedInvalidFolder(Folder)
case unableToRenameFeed(String, String)
case unableToRemoveFeed(WebFeed)
case unableToRemoveFeed(Feed)
var errorDescription: String? {
switch self {

View File

@ -28,7 +28,7 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl
private let getStreamContentsService: FeedlyGetStreamContentsService
private let log: OSLog
private var feedResourceId: FeedlyFeedResourceId?
var addCompletionHandler: ((Result<WebFeed, Error>) -> ())?
var addCompletionHandler: ((Result<Feed, Error>) -> ())?
init(account: Account, credentials: Credentials, url: String, feedName: String?, searchService: FeedlySearchService, addToCollectionService: FeedlyAddFeedToCollectionService, syncUnreadIdsService: FeedlyGetStreamIdsService, getStreamContentsService: FeedlyGetStreamContentsService, database: SyncDatabase, container: Container, progress: DownloadProgress, log: OSLog) throws {

View File

@ -46,7 +46,7 @@ final class FeedlyCreateFeedsForCollectionFoldersOperation: FeedlyOperation {
}
// Pair each Feed with its Folder.
var feedsAdded = Set<WebFeed>()
var feedsAdded = Set<Feed>()
let feedsAndFolders = pairs
.map({ (collectionFeeds, folder) -> [(FeedlyFeed, Folder)] in
@ -55,7 +55,7 @@ final class FeedlyCreateFeedsForCollectionFoldersOperation: FeedlyOperation {
}
})
.flatMap { $0 }
.compactMap { (collectionFeed, folder) -> (WebFeed, Folder) in
.compactMap { (collectionFeed, folder) -> (Feed, Folder) in
// find an existing feed previously added to the account
if let feed = account.existingWebFeed(withWebFeedID: collectionFeed.id) {

View File

@ -33,7 +33,7 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable {
}
public weak var account: Account?
public var topLevelWebFeeds: Set<WebFeed> = Set<WebFeed>()
public var topLevelWebFeeds: Set<Feed> = Set<Feed>()
public var folders: Set<Folder>? = nil // subfolders are not supported, so this is always nil
public var name: String? {
@ -100,25 +100,25 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable {
// MARK: Container
public func flattenedWebFeeds() -> Set<WebFeed> {
public func flattenedWebFeeds() -> Set<Feed> {
// Since sub-folders are not supported, its always the top-level feeds.
return topLevelWebFeeds
}
public func objectIsChild(_ object: AnyObject) -> Bool {
// Folders contain Feed objects only, at least for now.
guard let feed = object as? WebFeed else {
guard let feed = object as? Feed else {
return false
}
return topLevelWebFeeds.contains(feed)
}
public func addWebFeed(_ feed: WebFeed) {
public func addWebFeed(_ feed: Feed) {
topLevelWebFeeds.insert(feed)
postChildrenDidChangeNotification()
}
public func addFeeds(_ feeds: Set<WebFeed>) {
public func addFeeds(_ feeds: Set<Feed>) {
guard !feeds.isEmpty else {
return
}
@ -126,12 +126,12 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable {
postChildrenDidChangeNotification()
}
public func removeWebFeed(_ feed: WebFeed) {
public func removeWebFeed(_ feed: Feed) {
topLevelWebFeeds.remove(feed)
postChildrenDidChangeNotification()
}
public func removeFeeds(_ feeds: Set<WebFeed>) {
public func removeFeeds(_ feeds: Set<Feed>) {
guard !feeds.isEmpty else {
return
}
@ -164,7 +164,7 @@ private extension Folder {
unreadCount = updatedUnreadCount
}
func childrenContain(_ feed: WebFeed) -> Bool {
func childrenContain(_ feed: Feed) -> Bool {
return topLevelWebFeeds.contains(feed)
}
}

View File

@ -122,7 +122,7 @@ final class LocalAccountDelegate: AccountDelegate {
}
func createWebFeed(for account: Account, url urlString: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createWebFeed(for account: Account, url urlString: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
guard let url = URL(string: urlString) else {
completion(.failure(LocalAccountDelegateError.invalidParameter))
return
@ -131,28 +131,28 @@ final class LocalAccountDelegate: AccountDelegate {
createRSSWebFeed(for: account, url: url, editedName: name, container: container, completion: completion)
}
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
func renameWebFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
feed.editedName = name
completion(.success(()))
}
func removeWebFeed(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func removeWebFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
container.removeWebFeed(feed)
completion(.success(()))
}
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func moveWebFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
from.removeWebFeed(feed)
to.addWebFeed(feed)
completion(.success(()))
}
func addWebFeed(for account: Account, with feed: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func addWebFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
container.addWebFeed(feed)
completion(.success(()))
}
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func restoreWebFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
container.addWebFeed(feed)
completion(.success(()))
}
@ -219,7 +219,7 @@ final class LocalAccountDelegate: AccountDelegate {
extension LocalAccountDelegate: LocalAccountRefresherDelegate {
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: WebFeed) {
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: Feed) {
refreshProgress.completeTask()
}
@ -231,7 +231,7 @@ extension LocalAccountDelegate: LocalAccountRefresherDelegate {
private extension LocalAccountDelegate {
func createRSSWebFeed(for account: Account, url: URL, editedName: String?, container: Container, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createRSSWebFeed(for account: Account, url: URL, editedName: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
// We need to use a batch update here because we need to assign add the feed to the
// container before the name has been downloaded. This will put it in the sidebar

View File

@ -14,7 +14,7 @@ import Articles
import ArticlesDatabase
protocol LocalAccountRefresherDelegate {
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: WebFeed)
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: Feed)
func localAccountRefresher(_ refresher: LocalAccountRefresher, articleChanges: ArticleChanges, completion: @escaping () -> Void)
}
@ -28,7 +28,7 @@ final class LocalAccountRefresher {
return DownloadSession(delegate: self)
}()
public func refreshFeeds(_ feeds: Set<WebFeed>, completion: (() -> Void)? = nil) {
public func refreshFeeds(_ feeds: Set<Feed>, completion: (() -> Void)? = nil) {
guard !feeds.isEmpty else {
completion?()
return
@ -53,7 +53,7 @@ final class LocalAccountRefresher {
extension LocalAccountRefresher: DownloadSessionDelegate {
func downloadSession(_ downloadSession: DownloadSession, requestForRepresentedObject representedObject: AnyObject) -> URLRequest? {
guard let feed = representedObject as? WebFeed else {
guard let feed = representedObject as? Feed else {
return nil
}
guard let url = URL(string: feed.url) else {
@ -69,7 +69,7 @@ extension LocalAccountRefresher: DownloadSessionDelegate {
}
func downloadSession(_ downloadSession: DownloadSession, downloadDidCompleteForRepresentedObject representedObject: AnyObject, response: URLResponse?, data: Data, error: NSError?, completion: @escaping () -> Void) {
let feed = representedObject as! WebFeed
let feed = representedObject as! Feed
guard !data.isEmpty, !isSuspended else {
completion()
@ -120,7 +120,7 @@ extension LocalAccountRefresher: DownloadSessionDelegate {
}
func downloadSession(_ downloadSession: DownloadSession, shouldContinueAfterReceivingData data: Data, representedObject: AnyObject) -> Bool {
let feed = representedObject as! WebFeed
let feed = representedObject as! Feed
guard !isSuspended else {
delegate?.localAccountRefresher(self, requestCompletedFor: feed)
return false
@ -139,17 +139,17 @@ extension LocalAccountRefresher: DownloadSessionDelegate {
}
func downloadSession(_ downloadSession: DownloadSession, didReceiveUnexpectedResponse response: URLResponse, representedObject: AnyObject) {
let feed = representedObject as! WebFeed
let feed = representedObject as! Feed
delegate?.localAccountRefresher(self, requestCompletedFor: feed)
}
func downloadSession(_ downloadSession: DownloadSession, didReceiveNotModifiedResponse: URLResponse, representedObject: AnyObject) {
let feed = representedObject as! WebFeed
let feed = representedObject as! Feed
delegate?.localAccountRefresher(self, requestCompletedFor: feed)
}
func downloadSession(_ downloadSession: DownloadSession, didDiscardDuplicateRepresentedObject representedObject: AnyObject) {
let feed = representedObject as! WebFeed
let feed = representedObject as! Feed
delegate?.localAccountRefresher(self, requestCompletedFor: feed)
}

View File

@ -195,14 +195,14 @@ extension NewsBlurAccountDelegate {
}
func clearFolderRelationship(for feed: WebFeed, withFolderName folderName: String) {
func clearFolderRelationship(for feed: Feed, withFolderName folderName: String) {
if var folderRelationship = feed.folderRelationship {
folderRelationship[folderName] = nil
feed.folderRelationship = folderRelationship
}
}
func saveFolderRelationship(for feed: WebFeed, withFolderName folderName: String, id: String) {
func saveFolderRelationship(for feed: Feed, withFolderName folderName: String, id: String) {
if var folderRelationship = feed.folderRelationship {
folderRelationship[folderName] = id
feed.folderRelationship = folderRelationship
@ -412,7 +412,7 @@ extension NewsBlurAccountDelegate {
}
}
func createFeed(account: Account, feed: NewsBlurFeed?, name: String?, container: Container, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createFeed(account: Account, feed: NewsBlurFeed?, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
guard let feed = feed else {
completion(.failure(NewsBlurError.invalidParameter))
return
@ -445,7 +445,7 @@ extension NewsBlurAccountDelegate {
}
}
func downloadFeed(account: Account, feed: WebFeed, page: Int, completion: @escaping (Result<Void, Error>) -> Void) {
func downloadFeed(account: Account, feed: Feed, page: Int, completion: @escaping (Result<Void, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.retrieveStories(feedID: feed.webFeedID, page: page) { result in
@ -484,7 +484,7 @@ extension NewsBlurAccountDelegate {
}
}
func initialFeedDownload(account: Account, feed: WebFeed, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func initialFeedDownload(account: Account, feed: Feed, completion: @escaping (Result<Feed, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
// Download the initial articles
@ -513,7 +513,7 @@ extension NewsBlurAccountDelegate {
}
}
func deleteFeed(for account: Account, with feed: WebFeed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
// This error should never happen
guard let feedID = feed.externalID else {
completion(.failure(NewsBlurError.invalidParameter))

View File

@ -423,7 +423,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
}
}
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> ()) {
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> ()) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
let folderName = (container as? Folder)?.name
@ -442,7 +442,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
}
}
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> ()) {
func renameWebFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> ()) {
guard let feedID = feed.externalID else {
completion(.failure(NewsBlurError.invalidParameter))
return
@ -469,7 +469,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
}
}
func addWebFeed(for account: Account, with feed: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
func addWebFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
guard let folder = container as? Folder else {
DispatchQueue.main.async {
if let account = container as? Account {
@ -488,11 +488,11 @@ final class NewsBlurAccountDelegate: AccountDelegate {
completion(.success(()))
}
func removeWebFeed(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
func removeWebFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
deleteFeed(for: account, with: feed, from: container, completion: completion)
}
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
func moveWebFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
guard let feedID = feed.externalID else {
completion(.failure(NewsBlurError.invalidParameter))
return
@ -519,7 +519,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
}
}
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
func restoreWebFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
if let existingFeed = account.existingWebFeed(withURL: feed.url) {
account.addWebFeed(existingFeed, to: container) { result in
switch result {
@ -547,7 +547,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
return
}
var feedsToRestore: [WebFeed] = []
var feedsToRestore: [Feed] = []
for feed in folder.topLevelWebFeeds {
feedsToRestore.append(feed)
folder.topLevelWebFeeds.remove(feed)

View File

@ -390,7 +390,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createWebFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
guard let url = URL(string: url) else {
completion(.failure(ReaderAPIAccountDelegateError.invalidParameter))
return
@ -439,7 +439,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
func renameWebFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
// This error should never happen
guard let subscriptionID = feed.externalID else {
@ -466,7 +466,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
func removeWebFeed(for account: Account, with feed: WebFeed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func removeWebFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
guard let subscriptionID = feed.externalID else {
completion(.failure(ReaderAPIAccountDelegateError.invalidParameter))
return
@ -496,7 +496,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
}
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func moveWebFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if from is Account {
addWebFeed(for: account, with: feed, to: to, completion: completion)
} else {
@ -524,7 +524,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
}
func addWebFeed(for account: Account, with feed: WebFeed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func addWebFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if let folder = container as? Folder, let feedExternalID = feed.externalID {
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.createTagging(subscriptionID: feedExternalID, tagName: folder.name ?? "") { result in
@ -554,7 +554,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
}
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
func restoreWebFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if let existingFeed = account.existingWebFeed(withURL: feed.url) {
account.addWebFeed(existingFeed, to: container) { result in
@ -901,13 +901,13 @@ private extension ReaderAPIAccountDelegate {
}
func clearFolderRelationship(for feed: WebFeed, folderExternalID: String?) {
func clearFolderRelationship(for feed: Feed, folderExternalID: String?) {
guard var folderRelationship = feed.folderRelationship, let folderExternalID = folderExternalID else { return }
folderRelationship[folderExternalID] = nil
feed.folderRelationship = folderRelationship
}
func saveFolderRelationship(for feed: WebFeed, folderExternalID: String?, feedExternalID: String) {
func saveFolderRelationship(for feed: Feed, folderExternalID: String?, feedExternalID: String) {
guard let folderExternalID = folderExternalID else { return }
if var folderRelationship = feed.folderRelationship {
folderRelationship[folderExternalID] = feedExternalID
@ -917,7 +917,7 @@ private extension ReaderAPIAccountDelegate {
}
}
func createFeed( account: Account, subscription sub: ReaderAPISubscription, name: String?, container: Container, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func createFeed( account: Account, subscription sub: ReaderAPISubscription, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
DispatchQueue.main.async {
@ -948,7 +948,7 @@ private extension ReaderAPIAccountDelegate {
}
func initialFeedDownload( account: Account, feed: WebFeed, completion: @escaping (Result<WebFeed, Error>) -> Void) {
func initialFeedDownload( account: Account, feed: Feed, completion: @escaping (Result<Feed, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(5)
// Download the initial articles

View File

@ -349,10 +349,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat
}
@objc func webFeedSettingDidChange(_ note: Notification) {
guard let feed = note.object as? WebFeed, let key = note.userInfo?[WebFeed.WebFeedSettingUserInfoKey] as? String else {
guard let feed = note.object as? Feed, let key = note.userInfo?[Feed.WebFeedSettingUserInfoKey] as? String else {
return
}
if key == WebFeed.WebFeedSettingKey.homePageURL || key == WebFeed.WebFeedSettingKey.faviconURL {
if key == Feed.WebFeedSettingKey.homePageURL || key == Feed.WebFeedSettingKey.faviconURL {
let _ = faviconDownloader.favicon(for: feed)
}
}

View File

@ -20,7 +20,7 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
@IBOutlet weak var isNotifyAboutNewArticlesCheckBox: NSButton!
@IBOutlet weak var isReaderViewAlwaysOnCheckBox: NSButton?
private var feed: WebFeed? {
private var feed: Feed? {
didSet {
if feed != oldValue {
updateUI()
@ -42,7 +42,7 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
var windowTitle: String = NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {
return objects.count == 1 && objects.first is WebFeed
return objects.count == 1 && objects.first is Feed
}
// MARK: NSViewController
@ -123,7 +123,7 @@ extension WebFeedInspectorViewController: NSTextFieldDelegate {
private extension WebFeedInspectorViewController {
func updateFeed() {
guard let objects = objects, objects.count == 1, let singleFeed = objects.first as? WebFeed else {
guard let objects = objects, objects.count == 1, let singleFeed = objects.first as? Feed else {
feed = nil
return
}

View File

@ -170,7 +170,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
}
}
if let feed = currentFeedOrFolder as? WebFeed, let noteObject = noteObject as? WebFeed {
if let feed = currentFeedOrFolder as? Feed, let noteObject = noteObject as? Feed {
if feed == noteObject {
updateWindowTitle()
return
@ -627,7 +627,7 @@ extension MainWindowController: TimelineContainerViewControllerDelegate {
detailViewController?.setState(detailState, mode: mode)
}
func timelineRequestedWebFeedSelection(_: TimelineContainerViewController, webFeed: WebFeed) {
func timelineRequestedWebFeedSelection(_: TimelineContainerViewController, webFeed: Feed) {
sidebarViewController?.selectFeed(webFeed)
}

View File

@ -146,7 +146,7 @@ struct PasteboardWebFeed: Hashable {
}
}
extension WebFeed: PasteboardWriterOwner {
extension Feed: PasteboardWriterOwner {
public var pasteboardWriter: NSPasteboardWriting {
return WebFeedPasteboardWriter(webFeed: self)
@ -155,14 +155,14 @@ extension WebFeed: PasteboardWriterOwner {
@objc final class WebFeedPasteboardWriter: NSObject, NSPasteboardWriting {
private let webFeed: WebFeed
private let webFeed: Feed
static let webFeedUTI = "com.ranchero.webFeed"
static let webFeedUTIType = NSPasteboard.PasteboardType(rawValue: webFeedUTI)
static let webFeedUTIInternal = "com.ranchero.NetNewsWire-Evergreen.internal.webFeed"
static let webFeedUTIInternalType = NSPasteboard.PasteboardType(rawValue: webFeedUTIInternal)
init(webFeed: WebFeed) {
init(webFeed: Feed) {
self.webFeed = webFeed
}

View File

@ -136,7 +136,7 @@ private extension SidebarOutlineDataSource {
// Dont allow PseudoFeed to be dragged.
// This will have to be revisited later. For instance,
// user-created smart feeds should be draggable, maybe.
return node.representedObject is Folder || node.representedObject is WebFeed
return node.representedObject is Folder || node.representedObject is Feed
}
// MARK: - Drag and Drop
@ -249,7 +249,7 @@ private extension SidebarOutlineDataSource {
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
@ -309,7 +309,7 @@ private extension SidebarOutlineDataSource {
}
func copyWebFeedInAccount(node: Node, to parentNode: Node) {
guard let feed = node.representedObject as? WebFeed, let destination = parentNode.representedObject as? Container else {
guard let feed = node.representedObject as? Feed, let destination = parentNode.representedObject as? Container else {
return
}
@ -324,7 +324,7 @@ private extension SidebarOutlineDataSource {
}
func moveWebFeedInAccount(node: Node, to parentNode: Node) {
guard let feed = node.representedObject as? WebFeed,
guard let feed = node.representedObject as? Feed,
let source = node.parent?.representedObject as? Container,
let destination = parentNode.representedObject as? Container else {
return
@ -343,7 +343,7 @@ private extension SidebarOutlineDataSource {
}
func copyWebFeedBetweenAccounts(node: Node, to parentNode: Node) {
guard let feed = node.representedObject as? WebFeed,
guard let feed = node.representedObject as? Feed,
let destinationAccount = nodeAccount(parentNode),
let destinationContainer = parentNode.representedObject as? Container else {
return
@ -495,7 +495,7 @@ private extension SidebarOutlineDataSource {
}
func nodeRepresentsAnyDraggedFeed(_ node: Node, _ draggedFeeds: Set<PasteboardWebFeed>) -> Bool {
guard let feed = node.representedObject as? WebFeed else {
guard let feed = node.representedObject as? Feed else {
return false
}
for draggedFeed in draggedFeeds {
@ -520,7 +520,7 @@ private extension SidebarOutlineDataSource {
return account
} else if let folder = node.representedObject as? Folder {
return folder.account
} else if let webFeed = node.representedObject as? WebFeed {
} else if let webFeed = node.representedObject as? Feed {
return webFeed.account
} else {
return nil

View File

@ -31,8 +31,8 @@ extension SidebarViewController {
let object = objects.first!
switch object {
case is WebFeed:
return menuForWebFeed(object as! WebFeed)
case is Feed:
return menuForWebFeed(object as! Feed)
case is Folder:
return menuForFolder(object as! Folder)
case is PseudoFeed:
@ -93,7 +93,7 @@ extension SidebarViewController {
@objc func renameFromContextualMenu(_ sender: Any?) {
guard let window = view.window, let menuItem = sender as? NSMenuItem, let object = menuItem.representedObject as? DisplayNameProvider, object is WebFeed || object is Folder else {
guard let window = view.window, let menuItem = sender as? NSMenuItem, let object = menuItem.representedObject as? DisplayNameProvider, object is Feed || object is Folder else {
return
}
@ -106,7 +106,7 @@ extension SidebarViewController {
@objc func toggleNotificationsFromContextMenu(_ sender: Any?) {
guard let item = sender as? NSMenuItem,
let feed = item.representedObject as? WebFeed else {
let feed = item.representedObject as? Feed else {
return
}
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
@ -137,7 +137,7 @@ extension SidebarViewController {
@objc func toggleArticleExtractorFromContextMenu(_ sender: Any?) {
guard let item = sender as? NSMenuItem,
let feed = item.representedObject as? WebFeed else {
let feed = item.representedObject as? Feed else {
return
}
if feed.isArticleExtractorAlwaysOn == nil { feed.isArticleExtractorAlwaysOn = false }
@ -170,7 +170,7 @@ extension SidebarViewController: RenameWindowControllerDelegate {
func renameWindowController(_ windowController: RenameWindowController, didRenameObject object: Any, withNewName name: String) {
if let feed = object as? WebFeed {
if let feed = object as? Feed {
feed.rename(to: name) { result in
switch result {
case .success:
@ -206,7 +206,7 @@ private extension SidebarViewController {
return menu
}
func menuForWebFeed(_ webFeed: WebFeed) -> NSMenu? {
func menuForWebFeed(_ webFeed: Feed) -> NSMenu? {
let menu = NSMenu(title: "")
@ -338,7 +338,7 @@ private extension SidebarViewController {
func objectIsFeedOrFolder(_ object: Any) -> Bool {
return object is WebFeed || object is Folder
return object is Feed || object is Folder
}
func menuItem(_ title: String, _ action: Selector, _ representedObject: Any) -> NSMenuItem {

View File

@ -194,15 +194,15 @@ protocol SidebarDelegate: AnyObject {
}
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
guard let webFeed = note.userInfo?[UserInfoKey.webFeed] as? WebFeed else { return }
guard let webFeed = note.userInfo?[UserInfoKey.webFeed] as? Feed else { return }
configureCellsForRepresentedObject(webFeed)
}
@objc func webFeedSettingDidChange(_ note: Notification) {
guard let webFeed = note.object as? WebFeed, let key = note.userInfo?[WebFeed.WebFeedSettingUserInfoKey] as? String else {
guard let webFeed = note.object as? Feed, let key = note.userInfo?[Feed.WebFeedSettingUserInfoKey] as? String else {
return
}
if key == WebFeed.WebFeedSettingKey.homePageURL || key == WebFeed.WebFeedSettingKey.faviconURL {
if key == Feed.WebFeedSettingKey.homePageURL || key == Feed.WebFeedSettingKey.faviconURL {
configureCellsForRepresentedObject(webFeed)
}
}
@ -451,7 +451,7 @@ protocol SidebarDelegate: AnyObject {
if isReadFiltered, let sidebarItemID = feed.sidebarItemID {
self.treeControllerDelegate.addFilterException(sidebarItemID)
if let webFeed = feed as? WebFeed, let account = webFeed.account {
if let webFeed = feed as? Feed, let account = webFeed.account {
let parentFolder = account.sortedFolders?.first(where: { $0.objectIsChild(webFeed) })
if let parentFolderFeedID = parentFolder?.sidebarItemID {
self.treeControllerDelegate.addFilterException(parentFolderFeedID)
@ -524,11 +524,11 @@ private extension SidebarViewController {
return selectedNodes.first!
}
var singleSelectedWebFeed: WebFeed? {
var singleSelectedWebFeed: Feed? {
guard let node = singleSelectedNode else {
return nil
}
return node.representedObject as? WebFeed
return node.representedObject as? Feed
}
func addAllSelectedToFilterExceptions() {
@ -543,7 +543,7 @@ private extension SidebarViewController {
if folderFeed.account?.existingFolder(withID: folderFeed.folderID) != nil {
treeControllerDelegate.addFilterException(sidebarItemID)
}
} else if let webFeed = feed as? WebFeed {
} else if let webFeed = feed as? Feed {
if webFeed.account?.existingWebFeed(withWebFeedID: webFeed.webFeedID) != nil {
treeControllerDelegate.addFilterException(sidebarItemID)
addParentFolderToFilterExceptions(webFeed)
@ -744,7 +744,7 @@ private extension SidebarViewController {
guard let webFeedID = userInfo?[ArticlePathKey.webFeedID] as? String else {
return nil
}
if let node = startingNode.descendantNode(where: { ($0.representedObject as? WebFeed)?.webFeedID == webFeedID }) {
if let node = startingNode.descendantNode(where: { ($0.representedObject as? Feed)?.webFeedID == webFeedID }) {
return node
}
return nil
@ -771,7 +771,7 @@ private extension SidebarViewController {
}
func imageFor(_ node: Node) -> IconImage? {
if let feed = node.representedObject as? WebFeed, let feedIcon = IconImageCache.shared.imageForFeed(feed) {
if let feed = node.representedObject as? Feed, let feedIcon = IconImageCache.shared.imageForFeed(feed) {
return feedIcon
}
if let smallIconProvider = node.representedObject as? SmallIconProvider {
@ -861,7 +861,7 @@ private extension Node {
if representedObject === object {
return true
}
if let feed1 = object as? WebFeed, let feed2 = representedObject as? WebFeed {
if let feed1 = object as? Feed, let feed2 = representedObject as? Feed {
return feed1 == feed2
}
return false

View File

@ -12,7 +12,7 @@ import Articles
protocol TimelineContainerViewControllerDelegate: AnyObject {
func timelineSelectionDidChange(_: TimelineContainerViewController, articles: [Article]?, mode: TimelineSourceMode)
func timelineRequestedWebFeedSelection(_: TimelineContainerViewController, webFeed: WebFeed)
func timelineRequestedWebFeedSelection(_: TimelineContainerViewController, webFeed: Feed)
func timelineInvalidatedRestorationState(_: TimelineContainerViewController)
}
@ -141,7 +141,7 @@ extension TimelineContainerViewController: TimelineDelegate {
delegate?.timelineSelectionDidChange(self, articles: selectedArticles, mode: mode(for: timelineViewController))
}
func timelineRequestedWebFeedSelection(_: TimelineViewController, webFeed: WebFeed) {
func timelineRequestedWebFeedSelection(_: TimelineViewController, webFeed: Feed) {
delegate?.timelineRequestedWebFeedSelection(self, webFeed: webFeed)
}

View File

@ -65,7 +65,7 @@ extension TimelineViewController {
}
@objc func selectFeedInSidebarFromContextualMenu(_ sender: Any?) {
guard let menuItem = sender as? NSMenuItem, let webFeed = menuItem.representedObject as? WebFeed else {
guard let menuItem = sender as? NSMenuItem, let webFeed = menuItem.representedObject as? Feed else {
return
}
delegate?.timelineRequestedWebFeedSelection(self, webFeed: webFeed)
@ -164,7 +164,7 @@ private extension TimelineViewController {
menu.addSeparatorIfNeeded()
if articles.count == 1, let feed = articles.first!.webFeed {
if !(representedObjects?.contains(where: { $0 as? WebFeed == feed }) ?? false) {
if !(representedObjects?.contains(where: { $0 as? Feed == feed }) ?? false) {
menu.addItem(selectFeedInSidebarMenuItem(feed))
}
if let markAllMenuItem = markAllAsReadMenuItem(feed) {
@ -251,13 +251,13 @@ private extension TimelineViewController {
return menuItem(NSLocalizedString("Mark Below as Read", comment: "Command"), #selector(markBelowArticlesReadFromContextualMenu(_:)), articles)
}
func selectFeedInSidebarMenuItem(_ feed: WebFeed) -> NSMenuItem {
func selectFeedInSidebarMenuItem(_ feed: Feed) -> NSMenuItem {
let localizedMenuText = NSLocalizedString("Select “%@” in Sidebar", comment: "Command")
let formattedMenuText = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay)
return menuItem(formattedMenuText as String, #selector(selectFeedInSidebarFromContextualMenu(_:)), feed)
}
func markAllAsReadMenuItem(_ feed: WebFeed) -> NSMenuItem? {
func markAllAsReadMenuItem(_ feed: Feed) -> NSMenuItem? {
guard let articlesSet = try? feed.fetchArticles() else {
return nil
}

View File

@ -14,7 +14,7 @@ import os.log
protocol TimelineDelegate: AnyObject {
func timelineSelectionDidChange(_: TimelineViewController, selectedArticles: [Article]?)
func timelineRequestedWebFeedSelection(_: TimelineViewController, webFeed: WebFeed)
func timelineRequestedWebFeedSelection(_: TimelineViewController, webFeed: Feed)
func timelineInvalidatedRestorationState(_: TimelineViewController)
}
@ -111,7 +111,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
return
}
if let representedObjects = representedObjects, representedObjects.count == 1 && representedObjects.first is WebFeed {
if let representedObjects = representedObjects, representedObjects.count == 1 && representedObjects.first is Feed {
showFeedNames = {
for article in articles {
if !article.byline().isEmpty {
@ -594,7 +594,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
}
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
guard showIcons, let feed = note.userInfo?[UserInfoKey.webFeed] as? WebFeed else {
guard showIcons, let feed = note.userInfo?[UserInfoKey.webFeed] as? Feed else {
return
}
let indexesToReload = tableView.indexesOfAvailableRowsPassingTest { (row) -> Bool in
@ -636,7 +636,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
}
@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
}
@ -1226,14 +1226,14 @@ private extension TimelineViewController {
return representedObjects?.contains(where: { $0 is Folder }) ?? false
}
func representedObjectsContainsAnyWebFeed(_ webFeeds: Set<WebFeed>) -> Bool {
func representedObjectsContainsAnyWebFeed(_ webFeeds: Set<Feed>) -> Bool {
// Return true if theres a match or if a folder contains (recursively) one of feeds
guard let representedObjects = representedObjects else {
return false
}
for representedObject in representedObjects {
if let feed = representedObject as? WebFeed {
if let feed = representedObject as? Feed {
for oneFeed in webFeeds {
if feed.webFeedID == oneFeed.webFeedID || feed.url == oneFeed.url {
return true

View File

@ -73,10 +73,10 @@ extension NSApplication : ScriptingObjectContainer {
for 'articles of feed "The Shape of Everything" of account "On My Mac"'
*/
func allWebFeeds() -> [WebFeed] {
func allWebFeeds() -> [Feed] {
let accounts = AccountManager.shared.activeAccounts
let emptyFeeds:[WebFeed] = []
return accounts.reduce(emptyFeeds) { (result, nthAccount) -> [WebFeed] in
let emptyFeeds:[Feed] = []
return accounts.reduce(emptyFeeds) { (result, nthAccount) -> [Feed] in
let accountFeeds = Array(nthAccount.topLevelWebFeeds)
return result + accountFeeds
}

View File

@ -14,10 +14,10 @@ import Articles
@objc(ScriptableWebFeed)
class ScriptableWebFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
let webFeed:WebFeed
let webFeed:Feed
let container:ScriptingObjectContainer
init (_ webFeed:WebFeed, container:ScriptingObjectContainer) {
init (_ webFeed:Feed, container:ScriptingObjectContainer) {
self.webFeed = webFeed
self.container = container
}
@ -71,7 +71,7 @@ class ScriptableWebFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
return url
}
class func scriptableFeed(_ feed:WebFeed, account:Account, folder:Folder?) -> ScriptableWebFeed {
class func scriptableFeed(_ feed:Feed, account:Account, folder:Folder?) -> ScriptableWebFeed {
let scriptableAccount = ScriptableAccount(account)
if let folder = folder {
let scriptableFolder = ScriptableFolder(folder, container:scriptableAccount)

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,13 +135,13 @@ 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
}
@ -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(contentType: UTType.item)
attributeSet.title = feed.nameForDisplay
@ -278,7 +278,7 @@ private extension ActivityManager {
return "account_\(folder.account!.accountID)_folder_\(folder.nameForDisplay)"
}
static func identifier(for feed: WebFeed) -> String {
static func identifier(for feed: Feed) -> String {
return "account_\(feed.account!.accountID)_feed_\(feed.webFeedID)"
}
@ -286,7 +286,7 @@ private extension ActivityManager {
return "account_\(article.accountID)_feed_\(article.webFeedID)_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

@ -42,7 +42,7 @@ private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String:
extension Article {
var webFeed: WebFeed? {
var webFeed: Feed? {
return account?.existingWebFeed(withWebFeedID: webFeedID)
}
@ -121,7 +121,7 @@ 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]

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 {
}
private let queue: DispatchQueue
private var cache = [WebFeed: IconImage]() // faviconURL: RSImage
private var cache = [Feed: IconImage]() // faviconURL: RSImage
struct UserInfoKey {
static let faviconURL = "faviconURL"
@ -68,10 +68,10 @@ final class FaviconDownloader {
// 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)
@ -93,7 +93,7 @@ final class FaviconDownloader {
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 = sidebarItem as? PseudoFeed {
return imageForSmartFeed(smartFeed, sidebarItemID)
}
if let webFeed = sidebarItem as? WebFeed, let iconImage = imageForWebFeed(webFeed, sidebarItemID) {
if let webFeed = sidebarItem as? Feed, let iconImage = imageForWebFeed(webFeed, sidebarItemID) {
return iconImage
}
if let smallIconProvider = sidebarItem as? SmallIconProvider {
@ -80,7 +80,7 @@ private extension IconImageCache {
return nil
}
func imageForWebFeed(_ webFeed: WebFeed, _ feedID: SidebarItemIdentifier) -> IconImage? {
func imageForWebFeed(_ webFeed: Feed, _ feedID: SidebarItemIdentifier) -> IconImage? {
if let iconImage = webFeedIconImageCache[feedID] {
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 WebFeedTreeControllerDelegate {
}
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 WebFeedTreeControllerDelegate {
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
@ -79,7 +79,7 @@ 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)
return thumbnail

View File

@ -15,7 +15,7 @@ class WebFeedInspectorViewController: UITableViewController {
static let preferredContentSizeForFormSheetDisplay = CGSize(width: 460.0, height: 500.0)
var webFeed: WebFeed!
var webFeed: Feed!
@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var notifyAboutNewArticlesSwitch: UISwitch!
@IBOutlet weak var alwaysShowReaderViewSwitch: UISwitch!

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

@ -31,7 +31,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
// Validate account specific behaviors...
if destAccount.behaviors.contains(.disallowFeedInMultipleFolders),
let sourceNode = session.localDragSession?.items.first?.localObject as? Node,
let sourceWebFeed = sourceNode.representedObject as? WebFeed,
let sourceWebFeed = sourceNode.representedObject as? Feed,
sourceWebFeed.account?.accountID != destAccount.accountID && destAccount.hasWebFeed(withURL: sourceWebFeed.url) {
return UITableViewDropProposal(operation: .forbidden)
}
@ -91,7 +91,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 {
moveWebFeedInAccount(feed: webFeed, sourceContainer: source, destinationContainer: destination)
@ -100,7 +100,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
}
}
func moveWebFeedInAccount(feed: WebFeed, sourceContainer: Container, destinationContainer: Container) {
func moveWebFeedInAccount(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
guard sourceContainer !== destinationContainer else { return }
BatchUpdate.shared.start()
@ -115,7 +115,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
}
}
func moveWebFeedBetweenAccounts(feed: WebFeed, sourceContainer: Container, destinationContainer: Container) {
func moveWebFeedBetweenAccounts(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
if let existingFeed = destinationContainer.account?.existingWebFeed(withURL: feed.url) {

View File

@ -130,17 +130,17 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
@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.WebFeedSettingUserInfoKey] as? String else {
guard let webFeed = note.object as? Feed, let key = note.userInfo?[Feed.WebFeedSettingUserInfoKey] as? String else {
return
}
if key == WebFeed.WebFeedSettingKey.homePageURL || key == WebFeed.WebFeedSettingKey.faviconURL {
if key == Feed.WebFeedSettingKey.homePageURL || key == Feed.WebFeedSettingKey.faviconURL {
configureCellsForRepresentedObject(webFeed)
}
}
@ -268,7 +268,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
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("More", comment: "More")
let moreAction = UIContextualAction(style: .normal, title: moreTitle) { [weak self] (action, view, completion) in
@ -323,7 +323,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? SidebarItem 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)
@ -848,7 +848,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
@ -986,7 +986,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
}
@ -999,7 +999,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
}
@ -1013,7 +1013,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
@ -1027,7 +1027,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
@ -1042,7 +1042,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
@ -1082,7 +1082,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
}
@ -1110,7 +1110,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
}
@ -1182,7 +1182,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:
@ -1257,7 +1257,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

@ -450,7 +450,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
@ -641,7 +641,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

@ -537,7 +537,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
}
@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])
@ -549,7 +549,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
}
@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
}
@ -1103,15 +1103,15 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
markArticlesWithUndo([article], statusKey: .starred, flag: !article.status.starred)
}
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, animations: Animations = [], completion: (() -> Void)? = nil) {
func discloseWebFeed(_ webFeed: Feed, animations: Animations = [], completion: (() -> Void)? = nil) {
if isSearching {
masterTimelineViewController?.hideSearch()
}
@ -1177,7 +1177,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
}
func showFeedInspector() {
let timelineWebFeed = timelineFeed as? WebFeed
let timelineWebFeed = timelineFeed as? Feed
let articleFeed = currentArticle?.webFeed
guard let feed = timelineWebFeed ?? articleFeed else {
return
@ -1185,7 +1185,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
showFeedInspector(for: feed)
}
func showFeedInspector(for feed: WebFeed) {
func showFeedInspector(for feed: Feed) {
let feedInspectorNavController =
UIStoryboard.inspector.instantiateViewController(identifier: "FeedInspectorNavigationViewController") as! UINavigationController
let feedInspectorController = feedInspectorNavController.topViewController as! WebFeedInspectorViewController
@ -1229,7 +1229,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
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
@ -1457,7 +1457,7 @@ private extension SceneCoordinator {
if folderFeed.account?.existingFolder(withID: folderFeed.folderID) != nil {
treeControllerDelegate.addFilterException(sidebarItemID)
}
} else if let webFeed = feed as? WebFeed {
} else if let webFeed = feed as? Feed {
if webFeed.account?.existingWebFeed(withWebFeedID: webFeed.webFeedID) != nil {
treeControllerDelegate.addFilterException(sidebarItemID)
addParentFolderToFilterExceptions(webFeed)
@ -1630,7 +1630,7 @@ private extension SceneCoordinator {
func updateShowNamesAndIcons() {
if timelineFeed is WebFeed {
if timelineFeed is Feed {
showFeedNames = {
for article in articles {
if !article.byline().isEmpty {
@ -2041,11 +2041,11 @@ 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 {
return true
@ -2346,7 +2346,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)?.webFeedID == webFeedID }) {
return node
}
return nil