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]?) {
|
func syncFolders(_ account: Account, _ tags: [ReaderAPITag]?) {
|
||||||
|
|
||||||
guard let tags = tags else { return }
|
guard let tags = tags else { return }
|
||||||
|
assert(Thread.isMainThread)
|
||||||
|
|
||||||
os_log(.debug, log: log, "Syncing folders with %ld tags.", tags.count)
|
os_log(.debug, log: log, "Syncing folders with %ld tags.", tags.count)
|
||||||
|
|
||||||
|
@ -465,13 +465,11 @@ private extension ReaderAPIAccountDelegate {
|
||||||
if let folders = account.folders {
|
if let folders = account.folders {
|
||||||
folders.forEach { folder in
|
folders.forEach { folder in
|
||||||
if !tagNames.contains(folder.name ?? "") {
|
if !tagNames.contains(folder.name ?? "") {
|
||||||
DispatchQueue.main.sync {
|
for feed in folder.topLevelFeeds {
|
||||||
for feed in folder.topLevelFeeds {
|
account.addFeed(feed)
|
||||||
account.addFeed(feed)
|
clearFolderRelationship(for: feed, withFolderName: folder.name ?? "")
|
||||||
clearFolderRelationship(for: feed, withFolderName: folder.name ?? "")
|
|
||||||
}
|
|
||||||
account.removeFolder(folder)
|
|
||||||
}
|
}
|
||||||
|
account.removeFolder(folder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,9 +485,7 @@ private extension ReaderAPIAccountDelegate {
|
||||||
// Make any folders Reader has, but we don't
|
// Make any folders Reader has, but we don't
|
||||||
tagNames.forEach { tagName in
|
tagNames.forEach { tagName in
|
||||||
if !folderNames.contains(tagName) {
|
if !folderNames.contains(tagName) {
|
||||||
DispatchQueue.main.sync {
|
_ = account.ensureFolder(with: tagName)
|
||||||
_ = account.ensureFolder(with: tagName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +519,8 @@ private extension ReaderAPIAccountDelegate {
|
||||||
func syncFeeds(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
|
func syncFeeds(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
|
||||||
|
|
||||||
guard let subscriptions = subscriptions else { return }
|
guard let subscriptions = subscriptions else { return }
|
||||||
|
assert(Thread.isMainThread)
|
||||||
|
|
||||||
os_log(.debug, log: log, "Syncing feeds with %ld subscriptions.", subscriptions.count)
|
os_log(.debug, log: log, "Syncing feeds with %ld subscriptions.", subscriptions.count)
|
||||||
|
|
||||||
let subFeedIds = subscriptions.map { String($0.feedID) }
|
let subFeedIds = subscriptions.map { String($0.feedID) }
|
||||||
|
@ -533,9 +530,7 @@ private extension ReaderAPIAccountDelegate {
|
||||||
for folder in folders {
|
for folder in folders {
|
||||||
for feed in folder.topLevelFeeds {
|
for feed in folder.topLevelFeeds {
|
||||||
if !subFeedIds.contains(feed.feedID) {
|
if !subFeedIds.contains(feed.feedID) {
|
||||||
DispatchQueue.main.sync {
|
folder.removeFeed(feed)
|
||||||
folder.removeFeed(feed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,9 +538,7 @@ private extension ReaderAPIAccountDelegate {
|
||||||
|
|
||||||
for feed in account.topLevelFeeds {
|
for feed in account.topLevelFeeds {
|
||||||
if !subFeedIds.contains(feed.feedID) {
|
if !subFeedIds.contains(feed.feedID) {
|
||||||
DispatchQueue.main.sync {
|
account.removeFeed(feed)
|
||||||
account.removeFeed(feed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,17 +546,14 @@ private extension ReaderAPIAccountDelegate {
|
||||||
subscriptions.forEach { subscription in
|
subscriptions.forEach { subscription in
|
||||||
|
|
||||||
let subFeedId = String(subscription.feedID)
|
let subFeedId = String(subscription.feedID)
|
||||||
|
if let feed = account.idToFeedDictionary[subFeedId] {
|
||||||
DispatchQueue.main.sync {
|
feed.name = subscription.name
|
||||||
if let feed = account.idToFeedDictionary[subFeedId] {
|
feed.homePageURL = subscription.homePageURL
|
||||||
feed.name = subscription.name
|
} else {
|
||||||
feed.homePageURL = subscription.homePageURL
|
let feed = account.createFeed(with: subscription.name, url: subscription.url, feedID: subFeedId, homePageURL: subscription.homePageURL)
|
||||||
} else {
|
feed.iconURL = subscription.iconURL
|
||||||
let feed = account.createFeed(with: subscription.name, url: subscription.url, feedID: subFeedId, homePageURL: subscription.homePageURL)
|
feed.subscriptionID = String(subscription.feedID)
|
||||||
feed.iconURL = subscription.iconURL
|
account.addFeed(feed)
|
||||||
feed.subscriptionID = String(subscription.feedID)
|
|
||||||
account.addFeed(feed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -573,6 +563,7 @@ private extension ReaderAPIAccountDelegate {
|
||||||
func syncTaggings(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
|
func syncTaggings(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
|
||||||
|
|
||||||
guard let subscriptions = subscriptions else { return }
|
guard let subscriptions = subscriptions else { return }
|
||||||
|
assert(Thread.isMainThread)
|
||||||
|
|
||||||
os_log(.debug, log: log, "Syncing taggings with %ld subscriptions.", subscriptions.count)
|
os_log(.debug, log: log, "Syncing taggings with %ld subscriptions.", subscriptions.count)
|
||||||
|
|
||||||
|
@ -613,11 +604,9 @@ private extension ReaderAPIAccountDelegate {
|
||||||
// Move any feeds not in the folder to the account
|
// Move any feeds not in the folder to the account
|
||||||
for feed in folder.topLevelFeeds {
|
for feed in folder.topLevelFeeds {
|
||||||
if !taggingFeedIDs.contains(feed.feedID) {
|
if !taggingFeedIDs.contains(feed.feedID) {
|
||||||
DispatchQueue.main.sync {
|
folder.removeFeed(feed)
|
||||||
folder.removeFeed(feed)
|
clearFolderRelationship(for: feed, withFolderName: folder.name ?? "")
|
||||||
clearFolderRelationship(for: feed, withFolderName: folder.name ?? "")
|
account.addFeed(feed)
|
||||||
account.addFeed(feed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,10 +620,8 @@ private extension ReaderAPIAccountDelegate {
|
||||||
guard let feed = idDictionary[taggingFeedID] else {
|
guard let feed = idDictionary[taggingFeedID] else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
DispatchQueue.main.sync {
|
saveFolderRelationship(for: feed, withFolderName: folderName, id: String(subscription.feedID))
|
||||||
saveFolderRelationship(for: feed, withFolderName: folderName, id: String(subscription.feedID))
|
folder.addFeed(feed)
|
||||||
folder.addFeed(feed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,11 +630,9 @@ private extension ReaderAPIAccountDelegate {
|
||||||
let taggedFeedIDs = Set(subscriptions.map { String($0.feedID) })
|
let taggedFeedIDs = Set(subscriptions.map { String($0.feedID) })
|
||||||
|
|
||||||
// Remove all feeds from the account container that have a tag
|
// Remove all feeds from the account container that have a tag
|
||||||
DispatchQueue.main.sync {
|
for feed in account.topLevelFeeds {
|
||||||
for feed in account.topLevelFeeds {
|
if taggedFeedIDs.contains(feed.feedID) {
|
||||||
if taggedFeedIDs.contains(feed.feedID) {
|
account.removeFeed(feed)
|
||||||
account.removeFeed(feed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue