From 16be64c4400af22186819aaa99813b1d99e6834b Mon Sep 17 00:00:00 2001 From: Kiel Gillard Date: Wed, 16 Oct 2019 17:35:28 +1100 Subject: [PATCH] Feedly: removes redundant mapping of articles to feed IDs. --- .../FeedlyOrganiseParsedItemsByFeedOperation.swift | 13 +++---------- ...FeedlyUpdateAccountFeedsWithItemsOperation.swift | 13 ++----------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/Frameworks/Account/Feedly/Refresh/FeedlyOrganiseParsedItemsByFeedOperation.swift b/Frameworks/Account/Feedly/Refresh/FeedlyOrganiseParsedItemsByFeedOperation.swift index aa2e692c1..95fe8d37a 100644 --- a/Frameworks/Account/Feedly/Refresh/FeedlyOrganiseParsedItemsByFeedOperation.swift +++ b/Frameworks/Account/Feedly/Refresh/FeedlyOrganiseParsedItemsByFeedOperation.swift @@ -12,8 +12,7 @@ import os.log protocol FeedlyParsedItemsByFeedProviding { var providerName: String { get } - var allFeeds: Set { get } - func parsedItems(for feed: Feed) -> Set? + var parsedItemsKeyedByFeedId: [String: Set] { get } } /// Single responsibility is to group articles by their feeds. @@ -22,15 +21,9 @@ final class FeedlyOrganiseParsedItemsByFeedOperation: FeedlyOperation, FeedlyPar private let entryProvider: FeedlyEntryProviding private let log: OSLog - var allFeeds: Set { + var parsedItemsKeyedByFeedId: [String : Set] { assert(Thread.isMainThread) // Needs to be on main thread because Feed is a main-thread-only model type. - let keys = Set(itemsKeyedByFeedId.keys) - return account.flattenedFeeds().filter { keys.contains($0.feedID) } - } - - func parsedItems(for feed: Feed) -> Set? { - assert(Thread.isMainThread) // Needs to be on main thread because Feed is a main-thread-only model type. - return itemsKeyedByFeedId[feed.feedID] + return itemsKeyedByFeedId } var providerName: String { diff --git a/Frameworks/Account/Feedly/Refresh/FeedlyUpdateAccountFeedsWithItemsOperation.swift b/Frameworks/Account/Feedly/Refresh/FeedlyUpdateAccountFeedsWithItemsOperation.swift index f272f84e2..e6620a61a 100644 --- a/Frameworks/Account/Feedly/Refresh/FeedlyUpdateAccountFeedsWithItemsOperation.swift +++ b/Frameworks/Account/Feedly/Refresh/FeedlyUpdateAccountFeedsWithItemsOperation.swift @@ -29,19 +29,10 @@ final class FeedlyUpdateAccountFeedsWithItemsOperation: FeedlyOperation { return } - let allFeeds = organisedItemsProvider.allFeeds + let feedIDsAndItems = organisedItemsProvider.parsedItemsKeyedByFeedId - os_log(.debug, log: log, "Begin updating %i feeds for \"%@\"", allFeeds.count, organisedItemsProvider.providerName) - - var feedIDsAndItems = [String: Set]() - for feed in allFeeds { - guard let items = organisedItemsProvider.parsedItems(for: feed) else { - continue - } - feedIDsAndItems[feed.feedID] = items - } account.update(feedIDsAndItems: feedIDsAndItems, defaultRead: true) { - os_log(.debug, log: self.log, "Finished updating feeds for \"%@\"", self.organisedItemsProvider.providerName) + os_log(.debug, log: self.log, "Updated %i feeds for \"%@\"", feedIDsAndItems.count, self.organisedItemsProvider.providerName) self.didFinish() } }