diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index 22cd0be15..aef678300 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -93,55 +93,43 @@ final class LocalAccountDelegate: AccountDelegate { return } - DispatchQueue.global(qos: .userInitiated).async { + FeedFinder.find(url: url) { result in - FeedFinder.find(url: url) { result in + switch result { + case .success(let feedSpecifiers): - switch result { - case .success(let feedSpecifiers): - - 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 - } - - let feed = account.createFeed(with: nil, url: url.absoluteString, feedID: url.absoluteString, homePageURL: nil) - - 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 { + guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers), + let url = URL(string: bestFeedSpecifier.urlString) else { completion(.failure(AccountError.createErrorNotFound)) - } + return } + if account.hasFeed(withURL: bestFeedSpecifier.urlString) { + completion(.failure(AccountError.createErrorAlreadySubscribed)) + return + } + + let feed = account.createFeed(with: nil, url: url.absoluteString, feedID: url.absoluteString, homePageURL: nil) + + InitialFeedDownloader.download(url) { parsedFeed in + + if let parsedFeed = parsedFeed { + account.update(feed, with: parsedFeed, {}) + } + + feed.editedName = name + + container.addFeed(feed) + completion(.success(feed)) + + } + + case .failure: + completion(.failure(AccountError.createErrorNotFound)) } - + } - + } func renameFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result) -> Void) { diff --git a/Mac/MainWindow/AddFeed/AddFeedController.swift b/Mac/MainWindow/AddFeed/AddFeedController.swift index 7475be1b3..3760dbe88 100644 --- a/Mac/MainWindow/AddFeed/AddFeedController.swift +++ b/Mac/MainWindow/AddFeed/AddFeedController.swift @@ -62,7 +62,10 @@ class AddFeedController: AddFeedWindowControllerDelegate { account.createFeed(url: url.absoluteString, name: title, container: container) { result in - self.endShowingProgress() + DispatchQueue.main.async { + self.endShowingProgress() + } + BatchUpdate.shared.end() switch result {