@@ -25,7 +25,7 @@ public class PeopleUtils {
25
25
// We limit followers we display to 1000 to avoid API performance issues
26
26
public static final int FOLLOWER_PAGE_LIMIT = 50 ;
27
27
public static final int FETCH_LIMIT = 20 ;
28
- public static final int FETCH_ALL_USERS_LIMIT = 1000 ;
28
+ public static final int AUTHOR_FETCH_LIMIT = 100 ;
29
29
30
30
public static void fetchUsers (final SiteModel site , final int offset , final FetchUsersCallback callback ) {
31
31
RestRequest .Listener listener = new RestRequest .Listener () {
@@ -65,13 +65,15 @@ public void onErrorResponse(VolleyError volleyError) {
65
65
WordPress .getRestClientUtilsV1_1 ().get (path , params , null , listener , errorListener );
66
66
}
67
67
68
- public static void fetchAuthors (final SiteModel site , final FetchUsersCallback callback ) {
68
+ public static void fetchAuthors (final SiteModel site , final int offset , final FetchUsersCallback callback ) {
69
69
RestRequest .Listener listener = jsonObject -> {
70
70
if (jsonObject != null && callback != null ) {
71
71
try {
72
72
JSONArray jsonArray = jsonObject .getJSONArray ("users" );
73
73
List <Person > people = peopleListFromJSON (jsonArray , site .getId (), Person .PersonType .USER );
74
- callback .onSuccess (people , true );
74
+ int numberOfUsers = jsonObject .optInt ("found" );
75
+ boolean isEndOfList = (people .size () + offset ) >= numberOfUsers ;
76
+ callback .onSuccess (people , isEndOfList );
75
77
} catch (JSONException e ) {
76
78
AppLog .e (T .API , "JSON exception occurred while parsing the response for sites/%s/users: " + e );
77
79
callback .onError ();
@@ -87,8 +89,8 @@ public static void fetchAuthors(final SiteModel site, final FetchUsersCallback c
87
89
};
88
90
89
91
Map <String , String > params = new HashMap <>();
90
- params .put ("number" , Integer .toString (PeopleUtils .FETCH_ALL_USERS_LIMIT ));
91
- params .put ("offset" , "0" );
92
+ params .put ("number" , Integer .toString (PeopleUtils .AUTHOR_FETCH_LIMIT ));
93
+ params .put ("offset" , Integer . toString ( offset ) );
92
94
params .put ("order_by" , "display_name" );
93
95
params .put ("order" , "ASC" );
94
96
params .put ("authors_only" , "true" );
0 commit comments