diff --git a/Frameworks/Account/FeedProvider/Twitter/TwitterFeedProvider.swift b/Frameworks/Account/FeedProvider/Twitter/TwitterFeedProvider.swift index 6ce028472..bd7db0dc5 100644 --- a/Frameworks/Account/FeedProvider/Twitter/TwitterFeedProvider.swift +++ b/Frameworks/Account/FeedProvider/Twitter/TwitterFeedProvider.swift @@ -177,6 +177,10 @@ public struct TwitterFeedProvider: FeedProvider { var parameters = [String: Any]() var isSearch = false + if let sinceToken = webFeed.sinceToken, let sinceID = Int(sinceToken) { + parameters["since_id"] = sinceID + } + switch urlComponents.path { case "", "/", "/home": parameters["count"] = 100 @@ -208,8 +212,11 @@ public struct TwitterFeedProvider: FeedProvider { retrieveTweets(api: api, parameters: parameters, isSearch: isSearch) { result in switch result { - case .success(let tweets): - let parsedItems = self.makeParsedItems(webFeed.url, tweets) + case .success(let statuses): + if let sinceID = statuses.first?.idStr { + webFeed.sinceToken = sinceID + } + let parsedItems = self.makeParsedItems(webFeed.url, statuses) completion(.success(parsedItems)) case .failure(let error): completion(.failure(error)) diff --git a/Frameworks/Account/WebFeed.swift b/Frameworks/Account/WebFeed.swift index a964bc70b..db3a03aaf 100644 --- a/Frameworks/Account/WebFeed.swift +++ b/Frameworks/Account/WebFeed.swift @@ -153,6 +153,15 @@ public final class WebFeed: Feed, Renamable, Hashable { } } + public var sinceToken: String? { + get { + return metadata.sinceToken + } + set { + metadata.sinceToken = newValue + } + } + public var externalID: String? { get { return metadata.externalID diff --git a/Frameworks/Account/WebFeedMetadata.swift b/Frameworks/Account/WebFeedMetadata.swift index 424cdc638..3c2b2ed46 100644 --- a/Frameworks/Account/WebFeedMetadata.swift +++ b/Frameworks/Account/WebFeedMetadata.swift @@ -27,6 +27,7 @@ final class WebFeedMetadata: Codable { case isNotifyAboutNewArticles case isArticleExtractorAlwaysOn case conditionalGetInfo + case sinceToken case externalID = "subscriptionID" case folderRelationship } @@ -111,6 +112,14 @@ final class WebFeedMetadata: Codable { } } + var sinceToken: String? { + didSet { + if externalID != oldValue { + valueDidChange(.externalID) + } + } + } + var externalID: String? { didSet { if externalID != oldValue {