From 3a33c38d5ccd3f1e6153fba2aa270b5044c65b18 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 17 Dec 2019 21:24:17 -0800 Subject: [PATCH] Use an inner function in FeedbinAccountDelegate.refreshMissingArticles. I like this pattern because 1) it keeps the switch statement and its cases near each other, and 2) it puts all the actual processing in a single function, which makes it easier to see where processing happens. --- .../Account/Feedbin/FeedbinAccountDelegate.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index fa14f8cac..14d2d4e49 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -1130,9 +1130,7 @@ private extension FeedbinAccountDelegate { account.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate { result in - switch result { - case .success(let fetchedArticleIDs): - + func process(_ fetchedArticleIDs: Set) { let group = DispatchGroup() var errorOccurred = false @@ -1170,13 +1168,16 @@ private extension FeedbinAccountDelegate { completion(.success(())) } } - + } + + switch result { + case .success(let fetchedArticleIDs): + process(fetchedArticleIDs) case .failure(let error): + self.refreshProgress.completeTask() completion(.failure(error)) } - } - } func refreshArticles(_ account: Account, page: String?, updateFetchDate: Date?, completion: @escaping ((Result) -> Void)) {