Remove DispatchQueue.main.sync calls that are not appropriate anymore
This commit is contained in:
parent
fe9129ac4a
commit
9b552d8003
|
@ -454,8 +454,8 @@ private extension ReaderAPIAccountDelegate {
|
|||
}
|
||||
|
||||
func syncFolders(_ account: Account, _ tags: [ReaderAPITag]?) {
|
||||
|
||||
guard let tags = tags else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing folders with %ld tags.", tags.count)
|
||||
|
||||
|
@ -465,7 +465,6 @@ private extension ReaderAPIAccountDelegate {
|
|||
if let folders = account.folders {
|
||||
folders.forEach { folder in
|
||||
if !tagNames.contains(folder.name ?? "") {
|
||||
DispatchQueue.main.sync {
|
||||
for feed in folder.topLevelFeeds {
|
||||
account.addFeed(feed)
|
||||
clearFolderRelationship(for: feed, withFolderName: folder.name ?? "")
|
||||
|
@ -474,7 +473,6 @@ private extension ReaderAPIAccountDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let folderNames: [String] = {
|
||||
if let folders = account.folders {
|
||||
|
@ -487,11 +485,9 @@ private extension ReaderAPIAccountDelegate {
|
|||
// Make any folders Reader has, but we don't
|
||||
tagNames.forEach { tagName in
|
||||
if !folderNames.contains(tagName) {
|
||||
DispatchQueue.main.sync {
|
||||
_ = account.ensureFolder(with: tagName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -523,6 +519,7 @@ private extension ReaderAPIAccountDelegate {
|
|||
func syncFeeds(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
|
||||
|
||||
guard let subscriptions = subscriptions else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing feeds with %ld subscriptions.", subscriptions.count)
|
||||
|
||||
|
@ -533,28 +530,22 @@ private extension ReaderAPIAccountDelegate {
|
|||
for folder in folders {
|
||||
for feed in folder.topLevelFeeds {
|
||||
if !subFeedIds.contains(feed.feedID) {
|
||||
DispatchQueue.main.sync {
|
||||
folder.removeFeed(feed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for feed in account.topLevelFeeds {
|
||||
if !subFeedIds.contains(feed.feedID) {
|
||||
DispatchQueue.main.sync {
|
||||
account.removeFeed(feed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add any feeds we don't have and update any we do
|
||||
subscriptions.forEach { subscription in
|
||||
|
||||
let subFeedId = String(subscription.feedID)
|
||||
|
||||
DispatchQueue.main.sync {
|
||||
if let feed = account.idToFeedDictionary[subFeedId] {
|
||||
feed.name = subscription.name
|
||||
feed.homePageURL = subscription.homePageURL
|
||||
|
@ -564,7 +555,6 @@ private extension ReaderAPIAccountDelegate {
|
|||
feed.subscriptionID = String(subscription.feedID)
|
||||
account.addFeed(feed)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -573,6 +563,7 @@ private extension ReaderAPIAccountDelegate {
|
|||
func syncTaggings(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
|
||||
|
||||
guard let subscriptions = subscriptions else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing taggings with %ld subscriptions.", subscriptions.count)
|
||||
|
||||
|
@ -613,13 +604,11 @@ private extension ReaderAPIAccountDelegate {
|
|||
// Move any feeds not in the folder to the account
|
||||
for feed in folder.topLevelFeeds {
|
||||
if !taggingFeedIDs.contains(feed.feedID) {
|
||||
DispatchQueue.main.sync {
|
||||
folder.removeFeed(feed)
|
||||
clearFolderRelationship(for: feed, withFolderName: folder.name ?? "")
|
||||
account.addFeed(feed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add any feeds not in the folder
|
||||
let folderFeedIds = folder.topLevelFeeds.map { $0.feedID }
|
||||
|
@ -631,25 +620,21 @@ private extension ReaderAPIAccountDelegate {
|
|||
guard let feed = idDictionary[taggingFeedID] else {
|
||||
continue
|
||||
}
|
||||
DispatchQueue.main.sync {
|
||||
saveFolderRelationship(for: feed, withFolderName: folderName, id: String(subscription.feedID))
|
||||
folder.addFeed(feed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let taggedFeedIDs = Set(subscriptions.map { String($0.feedID) })
|
||||
|
||||
// Remove all feeds from the account container that have a tag
|
||||
DispatchQueue.main.sync {
|
||||
for feed in account.topLevelFeeds {
|
||||
if taggedFeedIDs.contains(feed.feedID) {
|
||||
account.removeFeed(feed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue