Handle refresh progress
This commit is contained in:
parent
0479bbd9f5
commit
fb07cfe187
|
@ -90,7 +90,11 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
completion(.failure(error))
|
DispatchQueue.main.async {
|
||||||
|
self.refreshProgress.clear()
|
||||||
|
let wrappedError = AccountError.wrappedError(error: error, account: account)
|
||||||
|
completion(.failure(wrappedError))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +235,10 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
||||||
case .success(let storyHashes):
|
case .success(let storyHashes):
|
||||||
self.refreshProgress.completeTask()
|
self.refreshProgress.completeTask()
|
||||||
|
|
||||||
|
if let count = storyHashes?.count, count > 0 {
|
||||||
|
self.refreshProgress.addToNumberOfTasksAndRemaining((count - 1) / 100 + 1)
|
||||||
|
}
|
||||||
|
|
||||||
self.refreshUnreadStories(for: account, hashes: storyHashes, updateFetchDate: nil, completion: completion)
|
self.refreshUnreadStories(for: account, hashes: storyHashes, updateFetchDate: nil, completion: completion)
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
completion(.failure(error))
|
completion(.failure(error))
|
||||||
|
@ -255,14 +263,12 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
||||||
|
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let stories):
|
case .success(let stories):
|
||||||
|
|
||||||
self.processStories(account: account, stories: stories) { error in
|
self.processStories(account: account, stories: stories) { error in
|
||||||
group.leave()
|
group.leave()
|
||||||
if error != nil {
|
if error != nil {
|
||||||
errorOccurred = true
|
errorOccurred = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
errorOccurred = true
|
errorOccurred = true
|
||||||
os_log(.error, log: self.log, "Refresh missing stories failed: %@.", error.localizedDescription)
|
os_log(.error, log: self.log, "Refresh missing stories failed: %@.", error.localizedDescription)
|
||||||
|
|
Loading…
Reference in New Issue