From 4890a33469329093dad0b6ed6296e707f7b9f108 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 4 Jul 2023 12:52:02 -0700 Subject: [PATCH] =?UTF-8?q?Rename=20FeedIdentifier=20and=20FeedIdentifiabl?= =?UTF-8?q?e=20to=20ItemIdentifier=20and=20ItemIdentifiable,=20since=20the?= =?UTF-8?q?y=E2=80=99re=20about=20identifying=20generic=20items=20rather?= =?UTF-8?q?=20than=20feeds.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Account/Sources/Account/AccountManager.swift | 4 +-- Account/Sources/Account/Feed.swift | 6 ++-- Account/Sources/Account/Folder.swift | 4 +-- ...dIdentifier.swift => ItemIdentifier.swift} | 28 +++++++++---------- Account/Sources/Account/WebFeed.swift | 4 +-- 5 files changed, 23 insertions(+), 23 deletions(-) rename Account/Sources/Account/{FeedIdentifier.swift => ItemIdentifier.swift} (71%) diff --git a/Account/Sources/Account/AccountManager.swift b/Account/Sources/Account/AccountManager.swift index 5215dafba..b3b121700 100644 --- a/Account/Sources/Account/AccountManager.swift +++ b/Account/Sources/Account/AccountManager.swift @@ -200,13 +200,13 @@ public final class AccountManager: UnreadCountProvider { return nil } - public func existingFeed(with feedID: FeedIdentifier) -> FeedProtocol? { + public func existingFeed(with feedID: ItemIdentifier) -> FeedProtocol? { switch feedID { case .folder(let accountID, let folderName): if let account = existingAccount(with: accountID) { return account.existingFolder(with: folderName) } - case .webFeed(let accountID, let webFeedID): + case .feed(let accountID, let webFeedID): if let account = existingAccount(with: accountID) { return account.existingWebFeed(withWebFeedID: webFeedID) } diff --git a/Account/Sources/Account/Feed.swift b/Account/Sources/Account/Feed.swift index c87fcc328..e7f50b5ef 100644 --- a/Account/Sources/Account/Feed.swift +++ b/Account/Sources/Account/Feed.swift @@ -15,7 +15,7 @@ public enum ReadFilterType { case alwaysRead } -public protocol FeedProtocol: FeedIdentifiable, ArticleFetcher, DisplayNameProvider, UnreadCountProvider { +public protocol FeedProtocol: ItemIdentifiable, ArticleFetcher, DisplayNameProvider, UnreadCountProvider { var account: Account? { get } var defaultReadFilterType: ReadFilterType { get } @@ -24,11 +24,11 @@ public protocol FeedProtocol: FeedIdentifiable, ArticleFetcher, DisplayNameProvi public extension FeedProtocol { - func readFiltered(readFilterEnabledTable: [FeedIdentifier: Bool]) -> Bool { + func readFiltered(readFilterEnabledTable: [ItemIdentifier: Bool]) -> Bool { guard defaultReadFilterType != .alwaysRead else { return true } - if let feedID = feedID, let readFilterEnabled = readFilterEnabledTable[feedID] { + if let itemID = itemID, let readFilterEnabled = readFilterEnabledTable[itemID] { return readFilterEnabled } else { return defaultReadFilterType == .read diff --git a/Account/Sources/Account/Folder.swift b/Account/Sources/Account/Folder.swift index 7257b62ad..14c9ccb63 100644 --- a/Account/Sources/Account/Folder.swift +++ b/Account/Sources/Account/Folder.swift @@ -24,12 +24,12 @@ public final class Folder: FeedProtocol, Renamable, Container, Hashable { return ContainerIdentifier.folder(accountID, nameForDisplay) } - public var feedID: FeedIdentifier? { + public var itemID: ItemIdentifier? { guard let accountID = account?.accountID else { assertionFailure("Expected feed.account, but got nil.") return nil } - return FeedIdentifier.folder(accountID, nameForDisplay) + return ItemIdentifier.folder(accountID, nameForDisplay) } public weak var account: Account? diff --git a/Account/Sources/Account/FeedIdentifier.swift b/Account/Sources/Account/ItemIdentifier.swift similarity index 71% rename from Account/Sources/Account/FeedIdentifier.swift rename to Account/Sources/Account/ItemIdentifier.swift index 05d3d7f23..79fa6ee35 100644 --- a/Account/Sources/Account/FeedIdentifier.swift +++ b/Account/Sources/Account/ItemIdentifier.swift @@ -1,5 +1,5 @@ // -// ArticleFetcherType.swift +// ItemIdentifier.swift // Account // // Created by Maurice Parker on 11/13/19. @@ -8,15 +8,15 @@ import Foundation -public protocol FeedIdentifiable { - var feedID: FeedIdentifier? { get } +public protocol ItemIdentifiable { + var itemID: ItemIdentifier? { get } } -public enum FeedIdentifier: CustomStringConvertible, Hashable, Equatable { +public enum ItemIdentifier: CustomStringConvertible, Hashable, Equatable { case smartFeed(String) // String is a unique identifier case script(String) // String is a unique identifier - case webFeed(String, String) // accountID, webFeedID + case feed(String, String) // accountID, feedID case folder(String, String) // accountID, folderName public var description: String { @@ -25,8 +25,8 @@ public enum FeedIdentifier: CustomStringConvertible, Hashable, Equatable { return "smartFeed: \(id)" case .script(let id): return "script: \(id)" - case .webFeed(let accountID, let webFeedID): - return "feed: \(accountID)_\(webFeedID)" + case .feed(let accountID, let feedID): + return "feed: \(accountID)_\(feedID)" case .folder(let accountID, let folderName): return "folder: \(accountID)_\(folderName)" } @@ -44,11 +44,11 @@ public enum FeedIdentifier: CustomStringConvertible, Hashable, Equatable { "type": "script", "id": id ] - case .webFeed(let accountID, let webFeedID): + case .feed(let accountID, let feedID): return [ "type": "feed", "accountID": accountID, - "webFeedID": webFeedID + "feedID": feedID ] case .folder(let accountID, let folderName): return [ @@ -65,16 +65,16 @@ public enum FeedIdentifier: CustomStringConvertible, Hashable, Equatable { switch type { case "smartFeed": guard let id = userInfo["id"] as? String else { return nil } - self = FeedIdentifier.smartFeed(id) + self = ItemIdentifier.smartFeed(id) case "script": guard let id = userInfo["id"] as? String else { return nil } - self = FeedIdentifier.script(id) + self = ItemIdentifier.script(id) case "feed": - guard let accountID = userInfo["accountID"] as? String, let webFeedID = userInfo["webFeedID"] as? String else { return nil } - self = FeedIdentifier.webFeed(accountID, webFeedID) + guard let accountID = userInfo["accountID"] as? String, let webFeedID = userInfo["feedID"] as? String else { return nil } + self = ItemIdentifier.feed(accountID, webFeedID) case "folder": guard let accountID = userInfo["accountID"] as? String, let folderName = userInfo["folderName"] as? String else { return nil } - self = FeedIdentifier.folder(accountID, folderName) + self = ItemIdentifier.folder(accountID, folderName) default: return nil } diff --git a/Account/Sources/Account/WebFeed.swift b/Account/Sources/Account/WebFeed.swift index b9759c586..83ddce64f 100644 --- a/Account/Sources/Account/WebFeed.swift +++ b/Account/Sources/Account/WebFeed.swift @@ -17,12 +17,12 @@ public final class WebFeed: FeedProtocol, Renamable, Hashable, ObservableObject return .none } - public var feedID: FeedIdentifier? { + public var itemID: ItemIdentifier? { guard let accountID = account?.accountID else { assertionFailure("Expected feed.account, but got nil.") return nil } - return FeedIdentifier.webFeed(accountID, webFeedID) + return ItemIdentifier.feed(accountID, webFeedID) } public weak var account: Account?