mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-23 08:09:41 +01:00
Implement since id as a parameter to limit the number returned
This commit is contained in:
parent
a522ec67b3
commit
55eea27c8d
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user