mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Rename FeedIdentifier and FeedIdentifiable to ItemIdentifier and ItemIdentifiable, since they’re about identifying generic items rather than feeds.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user