diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index 8cc07456b..b6c388f03 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -251,7 +251,9 @@ final class FeedbinAccountDelegate: AccountDelegate { return } + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.renameTag(oldName: folder.name ?? "", newName: name) { result in + self.refreshProgress.completeTask() switch result { case .success: DispatchQueue.main.async { @@ -285,7 +287,9 @@ final class FeedbinAccountDelegate: AccountDelegate { if let feedTaggingID = feed.folderRelationship?[folder.name ?? ""] { group.enter() + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.deleteTagging(taggingID: feedTaggingID) { result in + self.refreshProgress.completeTask() group.leave() switch result { case .success: @@ -302,7 +306,9 @@ final class FeedbinAccountDelegate: AccountDelegate { if let subscriptionID = feed.subscriptionID { group.enter() + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.deleteSubscription(subscriptionID: subscriptionID) { result in + self.refreshProgress.completeTask() group.leave() switch result { case .success: @@ -329,7 +335,9 @@ final class FeedbinAccountDelegate: AccountDelegate { func createFeed(for account: Account, url: String, name: String?, container: Container, completion: @escaping (Result) -> Void) { + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.createSubscription(url: url) { result in + self.refreshProgress.completeTask() switch result { case .success(let subResult): switch subResult { @@ -365,7 +373,9 @@ final class FeedbinAccountDelegate: AccountDelegate { return } + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.renameSubscription(subscriptionID: subscriptionID, newName: name) { result in + self.refreshProgress.completeTask() switch result { case .success: DispatchQueue.main.async { @@ -408,7 +418,9 @@ final class FeedbinAccountDelegate: AccountDelegate { func addFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result) -> Void) { if let folder = container as? Folder, let feedID = Int(feed.feedID) { + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.createTagging(feedID: feedID, name: folder.name ?? "") { result in + self.refreshProgress.completeTask() switch result { case .success(let taggingID): DispatchQueue.main.async { @@ -935,9 +947,13 @@ private extension FeedbinAccountDelegate { } func initialFeedDownload( account: Account, feed: Feed, completion: @escaping (Result) -> Void) { - + + // refreshArticles is being reused and will clear one of the tasks for us + refreshProgress.addToNumberOfTasksAndRemaining(4) + // Download the initial articles self.caller.retrieveEntries(feedID: feed.feedID) { result in + self.refreshProgress.completeTask() switch result { case .success(let (entries, page)): @@ -945,7 +961,9 @@ private extension FeedbinAccountDelegate { self.processEntries(account: account, entries: entries) { self.refreshArticles(account, page: page) { self.refreshArticleStatus(for: account) { + self.refreshProgress.completeTask() self.refreshMissingArticles(account) { + self.refreshProgress.completeTask() DispatchQueue.main.async { completion(.success(feed)) } @@ -1191,7 +1209,9 @@ private extension FeedbinAccountDelegate { func deleteTagging(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { if let folder = container as? Folder, let feedTaggingID = feed.folderRelationship?[folder.name ?? ""] { + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.deleteTagging(taggingID: feedTaggingID) { result in + self.refreshProgress.completeTask() switch result { case .success: DispatchQueue.main.async { @@ -1224,7 +1244,9 @@ private extension FeedbinAccountDelegate { return } + refreshProgress.addToNumberOfTasksAndRemaining(1) caller.deleteSubscription(subscriptionID: subscriptionID) { result in + self.refreshProgress.completeTask() switch result { case .success: DispatchQueue.main.async { diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index aef678300..c3fa7b022 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -92,19 +92,23 @@ final class LocalAccountDelegate: AccountDelegate { completion(.failure(LocalAccountDelegateError.invalidParameter)) return } - + + refreshProgress.addToNumberOfTasksAndRemaining(1) FeedFinder.find(url: url) { result in switch result { case .success(let feedSpecifiers): + guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers), let url = URL(string: bestFeedSpecifier.urlString) else { + self.refreshProgress.completeTask() completion(.failure(AccountError.createErrorNotFound)) return } if account.hasFeed(withURL: bestFeedSpecifier.urlString) { + self.refreshProgress.completeTask() completion(.failure(AccountError.createErrorAlreadySubscribed)) return } @@ -113,6 +117,8 @@ final class LocalAccountDelegate: AccountDelegate { InitialFeedDownloader.download(url) { parsedFeed in + self.refreshProgress.completeTask() + if let parsedFeed = parsedFeed { account.update(feed, with: parsedFeed, {}) } @@ -125,6 +131,7 @@ final class LocalAccountDelegate: AccountDelegate { } case .failure: + self.refreshProgress.completeTask() completion(.failure(AccountError.createErrorNotFound)) } diff --git a/submodules/RSWeb b/submodules/RSWeb index 1686ee1b1..4f8844750 160000 --- a/submodules/RSWeb +++ b/submodules/RSWeb @@ -1 +1 @@ -Subproject commit 1686ee1b1c5a4aef6ebe1ffd72b17d6defabd9fd +Subproject commit 4f8844750e9c25b0e43f9ead3de582d32a1321de