Resolved issue where local account feed finder could lock up the UI if an error was thrown. Issue #720
This commit is contained in:
parent
e7ec59f31f
commit
eb71e88845
|
@ -93,6 +93,8 @@ 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 {
|
||||||
|
@ -100,12 +102,16 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,12 +126,18 @@ 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(let error):
|
case .failure:
|
||||||
completion(.failure(error))
|
DispatchQueue.main.async {
|
||||||
|
completion(.failure(AccountError.createErrorNotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue