diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 6619a627a..c34f3c19a 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -679,6 +679,15 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, postChildrenDidChangeNotification() } + public func removeFeeds(_ feeds: Set) { + guard !feeds.isEmpty else { + return + } + topLevelFeeds.subtract(feeds) + structureDidChange() + postChildrenDidChangeNotification() + } + public func addFeed(_ feed: Feed) { topLevelFeeds.insert(feed) structureDidChange() diff --git a/Frameworks/Account/Feedly/Refresh/FeedlyCreateFeedsForCollectionFoldersOperation.swift b/Frameworks/Account/Feedly/Refresh/FeedlyCreateFeedsForCollectionFoldersOperation.swift index 9b0df05bc..b44e249fe 100644 --- a/Frameworks/Account/Feedly/Refresh/FeedlyCreateFeedsForCollectionFoldersOperation.swift +++ b/Frameworks/Account/Feedly/Refresh/FeedlyCreateFeedsForCollectionFoldersOperation.swift @@ -82,9 +82,7 @@ final class FeedlyCreateFeedsForCollectionFoldersOperation: FeedlyOperation { // Remove feeds without folders/collections. let feedsAfter = Set(feedsAndFolders.map { $0.0 }) let feedsWithoutCollections = feedsBefore.subtracting(feedsAfter) - for unmatched in feedsWithoutCollections { - account.removeFeed(unmatched) - } + account.removeFeeds(feedsWithoutCollections) if !feedsWithoutCollections.isEmpty { os_log(.debug, log: log, "Removed %i feeds", feedsWithoutCollections.count) diff --git a/Frameworks/Account/Folder.swift b/Frameworks/Account/Folder.swift index d5d68077e..77261889a 100644 --- a/Frameworks/Account/Folder.swift +++ b/Frameworks/Account/Folder.swift @@ -98,6 +98,14 @@ public final class Folder: DisplayNameProvider, Renamable, Container, UnreadCoun postChildrenDidChangeNotification() } + public func addFeeds(_ feeds: Set) { + guard !feeds.isEmpty else { + return + } + topLevelFeeds.formUnion(feeds) + postChildrenDidChangeNotification() + } + public func removeFeed(_ feed: Feed) { topLevelFeeds.remove(feed) postChildrenDidChangeNotification()