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,6 +722,7 @@ private extension FeedbinAccountDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add any feeds we don't have and update any we do
|
// Add any feeds we don't have and update any we do
|
||||||
|
var subscriptionsToAdd = Set<FeedbinSubscription>()
|
||||||
subscriptions.forEach { subscription in
|
subscriptions.forEach { subscription in
|
||||||
|
|
||||||
let subFeedId = String(subscription.feedID)
|
let subFeedId = String(subscription.feedID)
|
||||||
@ -732,13 +733,19 @@ private extension FeedbinAccountDelegate {
|
|||||||
feed.editedName = nil
|
feed.editedName = nil
|
||||||
feed.homePageURL = subscription.homePageURL
|
feed.homePageURL = subscription.homePageURL
|
||||||
feed.subscriptionID = String(subscription.subscriptionID)
|
feed.subscriptionID = String(subscription.subscriptionID)
|
||||||
} else {
|
}
|
||||||
let feed = account.createFeed(with: subscription.name, url: subscription.url, feedID: subFeedId, homePageURL: subscription.homePageURL)
|
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)
|
feed.subscriptionID = String(subscription.subscriptionID)
|
||||||
account.addFeed(feed)
|
account.addFeed(feed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func syncFeedFolderRelationship(_ account: Account, _ taggings: [FeedbinTagging]?) {
|
func syncFeedFolderRelationship(_ account: Account, _ taggings: [FeedbinTagging]?) {
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import Foundation
|
|||||||
import RSCore
|
import RSCore
|
||||||
import RSParser
|
import RSParser
|
||||||
|
|
||||||
struct FeedbinSubscription: Codable {
|
struct FeedbinSubscription: Hashable, Codable {
|
||||||
|
|
||||||
let subscriptionID: Int
|
let subscriptionID: Int
|
||||||
let feedID: Int
|
let feedID: Int
|
||||||
@ -26,6 +26,9 @@ struct FeedbinSubscription: Codable {
|
|||||||
case homePageURL = "site_url"
|
case homePageURL = "site_url"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func hash(into hasher: inout Hasher) {
|
||||||
|
hasher.combine(subscriptionID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FeedbinCreateSubscription: Codable {
|
struct FeedbinCreateSubscription: Codable {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user