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.

This commit is contained in:
Brent Simmons 2019-12-17 21:24:17 -08:00
parent db564d9cf9
commit 3a33c38d5c
1 changed files with 7 additions and 6 deletions

View File

@ -1130,9 +1130,7 @@ private extension FeedbinAccountDelegate {
account.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate { result in
switch result {
case .success(let fetchedArticleIDs):
func process(_ fetchedArticleIDs: Set<String>) {
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, Error>) -> Void)) {