Make sure that FeedFinder and InitialDownloader are running on the main thread.

This commit is contained in:
Maurice Parker 2019-06-10 08:21:03 -05:00
parent e42520cd9b
commit 93fbbd4cc3
2 changed files with 34 additions and 43 deletions

View File

@ -93,8 +93,6 @@ final class LocalAccountDelegate: AccountDelegate {
return return
} }
DispatchQueue.global(qos: .userInitiated).async {
FeedFinder.find(url: url) { result in FeedFinder.find(url: url) { result in
switch result { switch result {
@ -102,16 +100,12 @@ final class LocalAccountDelegate: AccountDelegate {
guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers), guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers),
let url = URL(string: bestFeedSpecifier.urlString) else { let url = URL(string: bestFeedSpecifier.urlString) else {
DispatchQueue.main.async {
completion(.failure(AccountError.createErrorNotFound)) completion(.failure(AccountError.createErrorNotFound))
}
return return
} }
if account.hasFeed(withURL: bestFeedSpecifier.urlString) { if account.hasFeed(withURL: bestFeedSpecifier.urlString) {
DispatchQueue.main.async {
completion(.failure(AccountError.createErrorAlreadySubscribed)) completion(.failure(AccountError.createErrorAlreadySubscribed))
}
return return
} }
@ -126,19 +120,13 @@ final class LocalAccountDelegate: AccountDelegate {
feed.editedName = name feed.editedName = name
container.addFeed(feed) container.addFeed(feed)
DispatchQueue.main.async {
completion(.success(feed)) completion(.success(feed))
}
} }
case .failure: case .failure:
DispatchQueue.main.async {
completion(.failure(AccountError.createErrorNotFound)) completion(.failure(AccountError.createErrorNotFound))
} }
}
}
} }

View File

@ -62,7 +62,10 @@ class AddFeedController: AddFeedWindowControllerDelegate {
account.createFeed(url: url.absoluteString, name: title, container: container) { result in account.createFeed(url: url.absoluteString, name: title, container: container) { result in
DispatchQueue.main.async {
self.endShowingProgress() self.endShowingProgress()
}
BatchUpdate.shared.end() BatchUpdate.shared.end()
switch result { switch result {