From f5f306f60f0175e6d63904410047706c398c4470 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 8 Sep 2019 21:17:57 -0700 Subject: [PATCH 1/3] Add comments to feed.iconURL and feed.faviconURL, explaining that these are set only if that info was part of the feed (which is a JSON-Feed-only feature). --- Frameworks/Account/Feed.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Frameworks/Account/Feed.swift b/Frameworks/Account/Feed.swift index f18c2c6dd..058bafdfc 100644 --- a/Frameworks/Account/Feed.swift +++ b/Frameworks/Account/Feed.swift @@ -39,6 +39,10 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha } } + // Note: this is available only if the icon URL was available in the feed. + // The icon URL is a JSON-Feed-only feature. + // Otherwise we find an icon URL via other means, but we don’t store it + // as part of feed metadata. public var iconURL: String? { get { return metadata.iconURL @@ -48,6 +52,10 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha } } + // Note: this is available only if the favicon URL was available in the feed. + // The favicon URL is a JSON-Feed-only feature. + // Otherwise we find a favicon URL via other means, but we don’t store it + // as part of feed metadata. public var faviconURL: String? { get { return metadata.faviconURL From 41c82eca15f434c04acf471206039f689f9bf054 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 8 Sep 2019 21:44:05 -0700 Subject: [PATCH 2/3] =?UTF-8?q?Rename=20existingFeed(with:)=20to=20existin?= =?UTF-8?q?gFeed(withFeedID:)=20to=20make=20it=20more=20clear.=20Make=20ac?= =?UTF-8?q?count.idToFeedDictionary=20private=20=E2=80=94=C2=A0callers=20s?= =?UTF-8?q?hould=20use=20existingFeed(withFeedID:).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Account/Account.swift | 6 +++--- Frameworks/Account/Container.swift | 6 +++--- Frameworks/Account/DataExtensions.swift | 2 +- Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift | 6 +++--- Shared/Data/ArticleUtilities.swift | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 63b30cd21..ee1d93c6a 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -119,7 +119,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, public var folders: Set? = Set() private var feedDictionaryNeedsUpdate = true private var _idToFeedDictionary = [String: Feed]() - var idToFeedDictionary: [String: Feed] { + private var idToFeedDictionary: [String: Feed] { if feedDictionaryNeedsUpdate { rebuildFeedDictionaries() } @@ -754,7 +754,7 @@ extension Account: FeedMetadataDelegate { func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys) { feedMetadataDirty = true - guard let feed = existingFeed(with: feedMetadata.feedID) else { + guard let feed = existingFeed(withFeedID: feedMetadata.feedID) else { return } feed.postFeedSettingDidChangeNotification(key) @@ -1151,7 +1151,7 @@ private extension Account { extension Account { - public func existingFeed(with feedID: String) -> Feed? { + public func existingFeed(withFeedID feedID: String) -> Feed? { return idToFeedDictionary[feedID] } } diff --git a/Frameworks/Account/Container.swift b/Frameworks/Account/Container.swift index 610ee69b8..4124e8314 100644 --- a/Frameworks/Account/Container.swift +++ b/Frameworks/Account/Container.swift @@ -36,7 +36,7 @@ public protocol Container: class { func has(_ feed: Feed) -> Bool func hasFeed(with feedID: 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 existingFolder(with name: String) -> Folder? func existingFolder(withID: Int) -> Folder? @@ -88,7 +88,7 @@ public extension Container { } func hasFeed(with feedID: String) -> Bool { - return existingFeed(with: feedID) != nil + return existingFeed(withFeedID: feedID) != nil } func hasFeed(withURL url: String) -> Bool { @@ -99,7 +99,7 @@ public extension Container { return flattenedFeeds().contains(feed) } - func existingFeed(with feedID: String) -> Feed? { + func existingFeed(withFeedID feedID: String) -> Feed? { for feed in flattenedFeeds() { if feed.feedID == feedID { return feed diff --git a/Frameworks/Account/DataExtensions.swift b/Frameworks/Account/DataExtensions.swift index bee0adaa7..95e144d20 100644 --- a/Frameworks/Account/DataExtensions.swift +++ b/Frameworks/Account/DataExtensions.swift @@ -53,7 +53,7 @@ public extension Article { } var feed: Feed? { - return account?.existingFeed(with: feedID) + return account?.existingFeed(withFeedID: feedID) } } diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index ac8aed461..7c9b49c58 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -706,7 +706,7 @@ private extension FeedbinAccountDelegate { let subFeedId = String(subscription.feedID) - if let feed = account.idToFeedDictionary[subFeedId] { + if let feed = account.existingFeed(withFeedID: subFeedId) { feed.name = subscription.name // If the name has been changed on the server remove the locally edited name feed.editedName = nil @@ -769,7 +769,7 @@ private extension FeedbinAccountDelegate { for tagging in groupedTaggings { let taggingFeedID = String(tagging.feedID) if !folderFeedIds.contains(taggingFeedID) { - guard let feed = account.idToFeedDictionary[taggingFeedID] else { + guard let feed = account.existingFeed(withFeedID: taggingFeedID) else { continue } saveFolderRelationship(for: feed, withFolderName: folderName, id: String(tagging.taggingID)) @@ -1063,7 +1063,7 @@ private extension FeedbinAccountDelegate { group.enter() - if let feed = account.idToFeedDictionary[feedID] { + if let feed = account.existingFeed(withFeedID: feedID) { DispatchQueue.main.async { account.update(feed, parsedItems: Set(mapItems), defaultRead: true) { group.leave() diff --git a/Shared/Data/ArticleUtilities.swift b/Shared/Data/ArticleUtilities.swift index 12df236ec..845735a03 100644 --- a/Shared/Data/ArticleUtilities.swift +++ b/Shared/Data/ArticleUtilities.swift @@ -42,7 +42,7 @@ private func accountAndArticlesDictionary(_ articles: Set
) -> [String: extension Article { var feed: Feed? { - return account?.existingFeed(with: feedID) + return account?.existingFeed(withFeedID: feedID) } var preferredLink: String? { From 03bf97df9036b13eb73c5d06b567f9d6264f3c05 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 8 Sep 2019 21:52:02 -0700 Subject: [PATCH 3/3] Fix parts of ReaderAPI implementation that I broke with an API change in Account. --- .../Account/ReaderAPI/ReaderAPIAccountDelegate.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index 3146fab0d..1d5e376a8 100644 --- a/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -549,7 +549,7 @@ private extension ReaderAPIAccountDelegate { subscriptions.forEach { subscription in let subFeedId = String(subscription.feedID) - if let feed = account.idToFeedDictionary[subFeedId] { + if let feed = account.existingFeed(withFeedID: subFeedId) { feed.name = subscription.name feed.homePageURL = subscription.homePageURL } else { @@ -619,8 +619,7 @@ private extension ReaderAPIAccountDelegate { for subscription in groupedTaggings { let taggingFeedID = String(subscription.feedID) if !folderFeedIds.contains(taggingFeedID) { - let idDictionary = account.idToFeedDictionary - guard let feed = idDictionary[taggingFeedID] else { + guard let feed = account.existingFeed(withFeedID: taggingFeedID) else { continue } saveFolderRelationship(for: feed, withFolderName: folderName, id: String(subscription.feedID)) @@ -880,7 +879,7 @@ private extension ReaderAPIAccountDelegate { group.enter() - if let feed = account.idToFeedDictionary[feedID] { + if let feed = account.existingFeed(withFeedID: feedID) { DispatchQueue.main.async { account.update(feed, parsedItems: Set(mapItems), defaultRead: true) { group.leave()