From 2f2efb5eac77f89541b5206d6dd99fa63795648f Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 2 Nov 2019 16:21:37 -0500 Subject: [PATCH] Change Feedbin to no longer clear lastFetchDate on errors. Issue #1233 --- Frameworks/Account/Feedbin/FeedbinAPICaller.swift | 7 ++----- .../Account/Feedbin/FeedbinAccountDelegate.swift | 13 ++++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Frameworks/Account/Feedbin/FeedbinAPICaller.swift b/Frameworks/Account/Feedbin/FeedbinAPICaller.swift index ff8cd03e0..271821d94 100644 --- a/Frameworks/Account/Feedbin/FeedbinAPICaller.swift +++ b/Frameworks/Account/Feedbin/FeedbinAPICaller.swift @@ -390,7 +390,7 @@ final class FeedbinAPICaller: NSObject { } - func retrieveEntries(completion: @escaping (Result<([FeedbinEntry]?, String?, Int?), Error>) -> Void) { + func retrieveEntries(completion: @escaping (Result<([FeedbinEntry]?, String?, Date?, Int?), Error>) -> Void) { let since: Date = { if let lastArticleFetch = accountMetadata?.lastArticleFetch { @@ -416,14 +416,12 @@ final class FeedbinAPICaller: NSObject { case .success(let (response, entries)): let dateInfo = HTTPDateInfo(urlResponse: response) - self.accountMetadata?.lastArticleFetch = dateInfo?.date let pagingInfo = HTTPLinkPagingInfo(urlResponse: response) let lastPageNumber = self.extractPageNumber(link: pagingInfo.lastPage) - completion(.success((entries, pagingInfo.nextPage, lastPageNumber))) + completion(.success((entries, pagingInfo.nextPage, dateInfo?.date, lastPageNumber))) case .failure(let error): - self.accountMetadata?.lastArticleFetch = nil completion(.failure(error)) } @@ -449,7 +447,6 @@ final class FeedbinAPICaller: NSObject { completion(.success((entries, pagingInfo.nextPage))) case .failure(let error): - self.accountMetadata?.lastArticleFetch = nil completion(.failure(error)) } diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index c8f7da41b..3aca53728 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -974,7 +974,7 @@ private extension FeedbinAccountDelegate { self.processEntries(account: account, entries: entries) { self.refreshArticleStatus(for: account) { - self.refreshArticles(account, page: page) { + self.refreshArticles(account, page: page, updateFetchDate: nil) { self.refreshProgress.completeTask() self.refreshMissingArticles(account) { self.refreshProgress.completeTask() @@ -1001,7 +1001,7 @@ private extension FeedbinAccountDelegate { caller.retrieveEntries() { result in switch result { - case .success(let (entries, page, lastPageNumber)): + case .success(let (entries, page, updateFetchDate, lastPageNumber)): if let last = lastPageNumber { self.refreshProgress.addToNumberOfTasksAndRemaining(last - 1) @@ -1010,7 +1010,7 @@ private extension FeedbinAccountDelegate { self.processEntries(account: account, entries: entries) { self.refreshProgress.completeTask() - self.refreshArticles(account, page: page) { + self.refreshArticles(account, page: page, updateFetchDate: updateFetchDate) { os_log(.debug, log: self.log, "Done refreshing articles.") completion() } @@ -1059,8 +1059,11 @@ private extension FeedbinAccountDelegate { } } - func refreshArticles(_ account: Account, page: String?, completion: @escaping (() -> Void)) { + func refreshArticles(_ account: Account, page: String?, updateFetchDate: Date?, completion: @escaping (() -> Void)) { guard let page = page else { + if let lastArticleFetch = updateFetchDate { + self.accountMetadata?.lastArticleFetch = lastArticleFetch + } completion() return } @@ -1072,7 +1075,7 @@ private extension FeedbinAccountDelegate { self.processEntries(account: account, entries: entries) { self.refreshProgress.completeTask() - self.refreshArticles(account, page: nextPage, completion: completion) + self.refreshArticles(account, page: nextPage, updateFetchDate: updateFetchDate, completion: completion) } case .failure(let error):