diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index bbd185238..55b939cfe 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -722,21 +722,28 @@ private extension FeedbinAccountDelegate { } // Add any feeds we don't have and update any we do + var subscriptionsToAdd = Set() subscriptions.forEach { subscription in - + let subFeedId = String(subscription.feedID) - + 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 feed.homePageURL = subscription.homePageURL feed.subscriptionID = String(subscription.subscriptionID) - } else { - let feed = account.createFeed(with: subscription.name, url: subscription.url, feedID: subFeedId, homePageURL: subscription.homePageURL) - feed.subscriptionID = String(subscription.subscriptionID) - account.addFeed(feed) } + else { + subscriptionsToAdd.insert(subscription) + } + } + + // Actually add subscriptions all in one go, so we don’t trigger various rebuilding things that Account does. + subscriptionsToAdd.forEach { subscription in + let feed = account.createFeed(with: subscription.name, url: subscription.url, feedID: String(subscription.feedID), homePageURL: subscription.homePageURL) + feed.subscriptionID = String(subscription.subscriptionID) + account.addFeed(feed) } } diff --git a/Frameworks/Account/Feedbin/FeedbinSubscription.swift b/Frameworks/Account/Feedbin/FeedbinSubscription.swift index 8d3ca1109..feac0e7dd 100644 --- a/Frameworks/Account/Feedbin/FeedbinSubscription.swift +++ b/Frameworks/Account/Feedbin/FeedbinSubscription.swift @@ -10,7 +10,7 @@ import Foundation import RSCore import RSParser -struct FeedbinSubscription: Codable { +struct FeedbinSubscription: Hashable, Codable { let subscriptionID: Int let feedID: Int @@ -26,6 +26,9 @@ struct FeedbinSubscription: Codable { case homePageURL = "site_url" } + public func hash(into hasher: inout Hasher) { + hasher.combine(subscriptionID) + } } struct FeedbinCreateSubscription: Codable {