Add MinID to Pagination
This commit is contained in:
parent
6bf95fc751
commit
b8bb5ae68c
13
mastodon.go
13
mastodon.go
|
@ -268,6 +268,7 @@ type Results struct {
|
|||
type Pagination struct {
|
||||
MaxID ID
|
||||
SinceID ID
|
||||
MinID ID
|
||||
Limit int64
|
||||
}
|
||||
|
||||
|
@ -291,6 +292,12 @@ func newPagination(rawlink string) (*Pagination, error) {
|
|||
return nil, err
|
||||
}
|
||||
p.SinceID = sinceID
|
||||
|
||||
minID, err := getPaginationID(link.URL, "min_id")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.MinID = minID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,9 +330,13 @@ func (p *Pagination) toValues() url.Values {
|
|||
func (p *Pagination) setValues(params url.Values) url.Values {
|
||||
if p.MaxID != "" {
|
||||
params.Set("max_id", string(p.MaxID))
|
||||
} else if p.SinceID != "" {
|
||||
}
|
||||
if p.SinceID != "" {
|
||||
params.Set("since_id", string(p.SinceID))
|
||||
}
|
||||
if p.MinID != "" {
|
||||
params.Set("min_id", string(p.MinID))
|
||||
}
|
||||
if p.Limit > 0 {
|
||||
params.Set("limit", fmt.Sprint(p.Limit))
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ func TestPaginationSetValues(t *testing.T) {
|
|||
if after.Get("max_id") != "123" {
|
||||
t.Fatalf("want %q but %q", "123", after.Get("max_id"))
|
||||
}
|
||||
if after.Get("since_id") != "" {
|
||||
if after.Get("since_id") != "789" {
|
||||
t.Fatalf("result should be empty string: %q", after.Get("since_id"))
|
||||
}
|
||||
if after.Get("limit") != "10" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user