Add feeds all in one go when processing Feedbin subscriptions. This is a performance enhancement.
This commit is contained in:
parent
1613a374d2
commit
50276233d1
@ -722,21 +722,28 @@ 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)
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user