Add feeds from Feedbin all in one go, which helps performance by not triggering Account’s rebuilding of its feedDictionary.

This commit is contained in:
Brent Simmons 2019-10-02 23:05:35 -07:00
parent cc187875d9
commit 1cfafe3014
2 changed files with 15 additions and 5 deletions

View File

@ -728,6 +728,7 @@ private extension FeedbinAccountDelegate {
}
// Add any feeds we don't have and update any we do
var subscriptionsToAdd = Set<FeedbinSubscription>()
subscriptions.forEach { subscription in
let subFeedId = String(subscription.feedID)
@ -738,11 +739,17 @@ private extension FeedbinAccountDelegate {
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 dont 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)
}
}

View File

@ -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 {