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,39 +93,51 @@ final class LocalAccountDelegate: AccountDelegate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
FeedFinder.find(url: url) { result in
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
|
|
||||||
switch result {
|
FeedFinder.find(url: url) { result in
|
||||||
case .success(let feedSpecifiers):
|
|
||||||
|
|
||||||
guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers),
|
switch result {
|
||||||
let url = URL(string: bestFeedSpecifier.urlString) else {
|
case .success(let feedSpecifiers):
|
||||||
completion(.failure(AccountError.createErrorNotFound))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if account.hasFeed(withURL: bestFeedSpecifier.urlString) {
|
guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers),
|
||||||
completion(.failure(AccountError.createErrorAlreadySubscribed))
|
let url = URL(string: bestFeedSpecifier.urlString) else {
|
||||||
return
|
DispatchQueue.main.async {
|
||||||
}
|
completion(.failure(AccountError.createErrorNotFound))
|
||||||
|
}
|
||||||
let feed = account.createFeed(with: nil, url: url.absoluteString, feedID: url.absoluteString, homePageURL: nil)
|
return
|
||||||
|
|
||||||
InitialFeedDownloader.download(url) { parsedFeed in
|
|
||||||
|
|
||||||
if let parsedFeed = parsedFeed {
|
|
||||||
account.update(feed, with: parsedFeed, {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
feed.editedName = name
|
if account.hasFeed(withURL: bestFeedSpecifier.urlString) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
completion(.failure(AccountError.createErrorAlreadySubscribed))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
container.addFeed(feed)
|
let feed = account.createFeed(with: nil, url: url.absoluteString, feedID: url.absoluteString, homePageURL: nil)
|
||||||
completion(.success(feed))
|
|
||||||
|
|
||||||
|
InitialFeedDownloader.download(url) { parsedFeed in
|
||||||
|
|
||||||
|
if let parsedFeed = parsedFeed {
|
||||||
|
account.update(feed, with: parsedFeed, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
feed.editedName = name
|
||||||
|
|
||||||
|
container.addFeed(feed)
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
completion(.success(feed))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
case .failure:
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
completion(.failure(AccountError.createErrorNotFound))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case .failure(let error):
|
|
||||||
completion(.failure(error))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue