Rename existingFeed(with:) to existingFeed(withFeedID:) to make it more clear. Make account.idToFeedDictionary private — callers should use existingFeed(withFeedID:).

This commit is contained in:
Brent Simmons 2019-09-08 21:44:05 -07:00
parent f5f306f60f
commit 41c82eca15
5 changed files with 11 additions and 11 deletions

View File

@ -119,7 +119,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
public var folders: Set<Folder>? = Set<Folder>() public var folders: Set<Folder>? = Set<Folder>()
private var feedDictionaryNeedsUpdate = true private var feedDictionaryNeedsUpdate = true
private var _idToFeedDictionary = [String: Feed]() private var _idToFeedDictionary = [String: Feed]()
var idToFeedDictionary: [String: Feed] { private var idToFeedDictionary: [String: Feed] {
if feedDictionaryNeedsUpdate { if feedDictionaryNeedsUpdate {
rebuildFeedDictionaries() rebuildFeedDictionaries()
} }
@ -754,7 +754,7 @@ extension Account: FeedMetadataDelegate {
func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys) { func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys) {
feedMetadataDirty = true feedMetadataDirty = true
guard let feed = existingFeed(with: feedMetadata.feedID) else { guard let feed = existingFeed(withFeedID: feedMetadata.feedID) else {
return return
} }
feed.postFeedSettingDidChangeNotification(key) feed.postFeedSettingDidChangeNotification(key)
@ -1151,7 +1151,7 @@ private extension Account {
extension Account { extension Account {
public func existingFeed(with feedID: String) -> Feed? { public func existingFeed(withFeedID feedID: String) -> Feed? {
return idToFeedDictionary[feedID] return idToFeedDictionary[feedID]
} }
} }

View File

@ -36,7 +36,7 @@ public protocol Container: class {
func has(_ feed: Feed) -> Bool func has(_ feed: Feed) -> Bool
func hasFeed(with feedID: String) -> Bool func hasFeed(with feedID: String) -> Bool
func hasFeed(withURL url: String) -> Bool func hasFeed(withURL url: String) -> Bool
func existingFeed(with feedID: String) -> Feed? func existingFeed(withFeedID: String) -> Feed?
func existingFeed(withURL url: String) -> Feed? func existingFeed(withURL url: String) -> Feed?
func existingFolder(with name: String) -> Folder? func existingFolder(with name: String) -> Folder?
func existingFolder(withID: Int) -> Folder? func existingFolder(withID: Int) -> Folder?
@ -88,7 +88,7 @@ public extension Container {
} }
func hasFeed(with feedID: String) -> Bool { func hasFeed(with feedID: String) -> Bool {
return existingFeed(with: feedID) != nil return existingFeed(withFeedID: feedID) != nil
} }
func hasFeed(withURL url: String) -> Bool { func hasFeed(withURL url: String) -> Bool {
@ -99,7 +99,7 @@ public extension Container {
return flattenedFeeds().contains(feed) return flattenedFeeds().contains(feed)
} }
func existingFeed(with feedID: String) -> Feed? { func existingFeed(withFeedID feedID: String) -> Feed? {
for feed in flattenedFeeds() { for feed in flattenedFeeds() {
if feed.feedID == feedID { if feed.feedID == feedID {
return feed return feed

View File

@ -53,7 +53,7 @@ public extension Article {
} }
var feed: Feed? { var feed: Feed? {
return account?.existingFeed(with: feedID) return account?.existingFeed(withFeedID: feedID)
} }
} }

View File

@ -706,7 +706,7 @@ private extension FeedbinAccountDelegate {
let subFeedId = String(subscription.feedID) let subFeedId = String(subscription.feedID)
if let feed = account.idToFeedDictionary[subFeedId] { if let feed = account.existingFeed(withFeedID: subFeedId) {
feed.name = subscription.name feed.name = subscription.name
// If the name has been changed on the server remove the locally edited name // If the name has been changed on the server remove the locally edited name
feed.editedName = nil feed.editedName = nil
@ -769,7 +769,7 @@ private extension FeedbinAccountDelegate {
for tagging in groupedTaggings { for tagging in groupedTaggings {
let taggingFeedID = String(tagging.feedID) let taggingFeedID = String(tagging.feedID)
if !folderFeedIds.contains(taggingFeedID) { if !folderFeedIds.contains(taggingFeedID) {
guard let feed = account.idToFeedDictionary[taggingFeedID] else { guard let feed = account.existingFeed(withFeedID: taggingFeedID) else {
continue continue
} }
saveFolderRelationship(for: feed, withFolderName: folderName, id: String(tagging.taggingID)) saveFolderRelationship(for: feed, withFolderName: folderName, id: String(tagging.taggingID))
@ -1063,7 +1063,7 @@ private extension FeedbinAccountDelegate {
group.enter() group.enter()
if let feed = account.idToFeedDictionary[feedID] { if let feed = account.existingFeed(withFeedID: feedID) {
DispatchQueue.main.async { DispatchQueue.main.async {
account.update(feed, parsedItems: Set(mapItems), defaultRead: true) { account.update(feed, parsedItems: Set(mapItems), defaultRead: true) {
group.leave() group.leave()

View File

@ -42,7 +42,7 @@ private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String:
extension Article { extension Article {
var feed: Feed? { var feed: Feed? {
return account?.existingFeed(with: feedID) return account?.existingFeed(withFeedID: feedID)
} }
var preferredLink: String? { var preferredLink: String? {