Fix pagination for mstdn command

This commit is contained in:
178inaba 2017-05-05 00:18:17 +09:00
parent 5fad354d1a
commit dd0b467062
4 changed files with 18 additions and 5 deletions

View file

@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"time"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli"
@ -16,9 +17,20 @@ func cmdFollowers(c *cli.Context) error {
if err != nil {
return err
}
followers, err := client.GetAccountFollowers(context.Background(), account.ID)
if err != nil {
return err
var maxID *int64
var followers []*mastodon.Account
for {
fs, pg, err := client.GetAccountFollowers(
context.Background(), account.ID, &mastodon.Pagination{MaxID: maxID})
if err != nil {
return err
}
followers = append(followers, fs...)
if pg.MaxID == nil {
break
}
maxID = pg.MaxID
time.Sleep(10 * time.Second)
}
s := newScreen(config)
for _, follower := range followers {