Update last article fetch time
This commit is contained in:
parent
a784b11d1c
commit
f0fe308c7b
|
@ -222,7 +222,7 @@ extension NewsBlurAccountDelegate {
|
|||
|
||||
caller.retrieveStories(hashes: hashesToFetch) { result in
|
||||
switch result {
|
||||
case .success(let stories):
|
||||
case .success((let stories, let date)):
|
||||
self.processStories(account: account, stories: stories) { result in
|
||||
self.refreshProgress.completeTask()
|
||||
|
||||
|
@ -231,7 +231,7 @@ extension NewsBlurAccountDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
self.refreshUnreadStories(for: account, hashes: Array(hashes[numberOfStories...]), updateFetchDate: updateFetchDate) { result in
|
||||
self.refreshUnreadStories(for: account, hashes: Array(hashes[numberOfStories...]), updateFetchDate: date) { result in
|
||||
os_log(.debug, log: self.log, "Done refreshing stories.")
|
||||
switch result {
|
||||
case .success:
|
||||
|
@ -401,7 +401,7 @@ extension NewsBlurAccountDelegate {
|
|||
|
||||
caller.retrieveStories(feedID: feed.webFeedID, page: page) { result in
|
||||
switch result {
|
||||
case .success(let stories):
|
||||
case .success((let stories, _)):
|
||||
// No more stories
|
||||
guard let stories = stories, stories.count > 0 else {
|
||||
self.refreshProgress.completeTask()
|
||||
|
@ -410,7 +410,14 @@ extension NewsBlurAccountDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
let since = Calendar.current.date(byAdding: .month, value: -3, to: Date())
|
||||
let since: Date? = {
|
||||
if let lastArticleFetch = self.accountMetadata?.lastArticleFetchStartTime {
|
||||
return lastArticleFetch
|
||||
} else {
|
||||
return Calendar.current.date(byAdding: .month, value: -3, to: Date())
|
||||
}
|
||||
}()
|
||||
|
||||
self.processStories(account: account, stories: stories, since: since) { result in
|
||||
self.refreshProgress.completeTask()
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ final class NewsBlurAPICaller: NSObject {
|
|||
)
|
||||
}
|
||||
|
||||
func retrieveStories(feedID: String, page: Int, completion: @escaping (Result<[NewsBlurStory]?, Error>) -> Void) {
|
||||
func retrieveStories(feedID: String, page: Int, completion: @escaping (Result<([NewsBlurStory]?, Date?), Error>) -> Void) {
|
||||
let url = baseURL
|
||||
.appendingPathComponent("reader/feed/\(feedID)")
|
||||
.appendingQueryItems([
|
||||
|
@ -138,15 +138,15 @@ final class NewsBlurAPICaller: NSObject {
|
|||
|
||||
requestData(callURL: url, resultType: NewsBlurStoriesResponse.self) { result in
|
||||
switch result {
|
||||
case .success((_, let payload)):
|
||||
completion(.success(payload?.stories))
|
||||
case .success(let (response, payload)):
|
||||
completion(.success((payload?.stories, HTTPDateInfo(urlResponse: response)?.date)))
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func retrieveStories(hashes: [NewsBlurStoryHash], completion: @escaping (Result<[NewsBlurStory]?, Error>) -> Void) {
|
||||
func retrieveStories(hashes: [NewsBlurStoryHash], completion: @escaping (Result<([NewsBlurStory]?, Date?), Error>) -> Void) {
|
||||
let url = baseURL
|
||||
.appendingPathComponent("reader/river_stories")
|
||||
.appendingQueryItem(.init(name: "include_hidden", value: "true"))?
|
||||
|
@ -156,8 +156,8 @@ final class NewsBlurAPICaller: NSObject {
|
|||
|
||||
requestData(callURL: url, resultType: NewsBlurStoriesResponse.self) { result in
|
||||
switch result {
|
||||
case .success((_, let payload)):
|
||||
completion(.success(payload?.stories))
|
||||
case .success(let (response, payload)):
|
||||
completion(.success((payload?.stories, HTTPDateInfo(urlResponse: response)?.date)))
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
|||
self.caller.retrieveStories(hashes: chunk) { result in
|
||||
|
||||
switch result {
|
||||
case .success(let stories):
|
||||
case .success((let stories, _)):
|
||||
self.processStories(account: account, stories: stories) { result in
|
||||
group.leave()
|
||||
if case .failure = result {
|
||||
|
|
Loading…
Reference in New Issue