From 8331d37dc1ba3474dece84fbecef25249c77a6e2 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 17 Apr 2020 08:58:06 -0500 Subject: [PATCH] Fix add new feed to keep sidebar consistent. --- .../Account/LocalAccount/LocalAccountDelegate.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index 29ae9a64d..eb44b564e 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -192,6 +192,7 @@ final class LocalAccountDelegate: AccountDelegate { // Use the standard feed finder to download and process the RSS feed refreshProgress.addToNumberOfTasksAndRemaining(1) + BatchUpdate.shared.start() FeedFinder.find(url: url) { result in switch result { @@ -199,34 +200,39 @@ final class LocalAccountDelegate: AccountDelegate { guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers), let url = URL(string: bestFeedSpecifier.urlString) else { self.refreshProgress.completeTask() + BatchUpdate.shared.end() completion(.failure(AccountError.createErrorNotFound)) return } if account.hasWebFeed(withURL: bestFeedSpecifier.urlString) { self.refreshProgress.completeTask() + BatchUpdate.shared.end() completion(.failure(AccountError.createErrorAlreadySubscribed)) return } let feed = account.createWebFeed(with: nil, url: url.absoluteString, webFeedID: url.absoluteString, homePageURL: nil) feed.editedName = name + container.addWebFeed(feed) InitialFeedDownloader.download(url) { parsedFeed in self.refreshProgress.completeTask() if let parsedFeed = parsedFeed { account.update(feed, with: parsedFeed, {_ in - container.addWebFeed(feed) + BatchUpdate.shared.end() completion(.success(feed)) }) } else { + BatchUpdate.shared.end() completion(.failure(AccountError.createErrorNotFound)) } } case .failure: + BatchUpdate.shared.end() self.refreshProgress.completeTask() completion(.failure(AccountError.createErrorNotFound)) }