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

View File

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