use refresh indicator to track all network activity. Issue #759
This commit is contained in:
parent
14577fea2f
commit
f6677367ec
|
@ -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<Feed, Error>) -> 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, Error>) -> 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 {
|
||||
|
@ -936,8 +948,12 @@ private extension FeedbinAccountDelegate {
|
|||
|
||||
func initialFeedDownload( account: Account, feed: Feed, completion: @escaping (Result<Feed, Error>) -> 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, Error>) -> 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 {
|
||||
|
|
|
@ -93,18 +93,22 @@ final class LocalAccountDelegate: AccountDelegate {
|
|||
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))
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1686ee1b1c5a4aef6ebe1ffd72b17d6defabd9fd
|
||||
Subproject commit 4f8844750e9c25b0e43f9ead3de582d32a1321de
|
Loading…
Reference in New Issue