Remove references to DispatchQueue.main.sync and assert that we’re on the main thread.
This commit is contained in:
parent
1e82ad4845
commit
597c57e61c
|
@ -592,8 +592,8 @@ private extension FeedbinAccountDelegate {
|
|||
}
|
||||
|
||||
func syncFolders(_ account: Account, _ tags: [FeedbinTag]?) {
|
||||
|
||||
guard let tags = tags else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing folders with %ld tags.", tags.count)
|
||||
|
||||
|
@ -603,7 +603,6 @@ private extension FeedbinAccountDelegate {
|
|||
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 ?? "")
|
||||
|
@ -612,7 +611,6 @@ private extension FeedbinAccountDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let folderNames: [String] = {
|
||||
if let folders = account.folders {
|
||||
|
@ -625,11 +623,9 @@ private extension FeedbinAccountDelegate {
|
|||
// Make any folders Feedbin has, but we don't
|
||||
tagNames.forEach { tagName in
|
||||
if !folderNames.contains(tagName) {
|
||||
DispatchQueue.main.sync {
|
||||
_ = account.ensureFolder(with: tagName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -681,6 +677,7 @@ private extension FeedbinAccountDelegate {
|
|||
func syncFeeds(_ account: Account, _ subscriptions: [FeedbinSubscription]?) {
|
||||
|
||||
guard let subscriptions = subscriptions else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing feeds with %ld subscriptions.", subscriptions.count)
|
||||
|
||||
|
@ -691,28 +688,23 @@ private extension FeedbinAccountDelegate {
|
|||
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
|
||||
// If the name has been changed on the server remove the locally edited name
|
||||
|
@ -725,14 +717,12 @@ private extension FeedbinAccountDelegate {
|
|||
account.addFeed(feed)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func syncTaggings(_ account: Account, _ taggings: [FeedbinTagging]?) {
|
||||
|
||||
guard let taggings = taggings else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing taggings with %ld taggings.", taggings.count)
|
||||
|
||||
|
@ -766,13 +756,11 @@ private extension FeedbinAccountDelegate {
|
|||
// 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 }
|
||||
|
@ -783,19 +771,16 @@ private extension FeedbinAccountDelegate {
|
|||
guard let feed = account.idToFeedDictionary[taggingFeedID] else {
|
||||
continue
|
||||
}
|
||||
DispatchQueue.main.sync {
|
||||
saveFolderRelationship(for: feed, withFolderName: folderName, id: String(tagging.taggingID))
|
||||
folder.addFeed(feed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let taggedFeedIDs = Set(taggings.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)
|
||||
|
@ -803,8 +788,6 @@ private extension FeedbinAccountDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func syncFavicons(_ account: Account, _ icons: [FeedbinIcon]?) {
|
||||
|
||||
guard let icons = icons else { return }
|
||||
|
@ -821,7 +804,6 @@ private extension FeedbinAccountDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue