mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-24 07:37:30 +00:00
fix comments paging issue
This commit is contained in:
parent
66acf16d53
commit
dc77f16b13
@ -5,6 +5,5 @@ import awais.instagrabber.models.Comment
|
|||||||
data class CommentsFetchResponse(
|
data class CommentsFetchResponse(
|
||||||
val commentCount: Int,
|
val commentCount: Int,
|
||||||
val nextMinId: String?,
|
val nextMinId: String?,
|
||||||
val comments: List<Comment>?,
|
val comments: List<Comment>?
|
||||||
val hasMoreComments: Boolean
|
|
||||||
)
|
)
|
@ -32,6 +32,7 @@ import awais.instagrabber.utils.Constants;
|
|||||||
import awais.instagrabber.utils.CookieUtils;
|
import awais.instagrabber.utils.CookieUtils;
|
||||||
import awais.instagrabber.utils.CoroutineUtilsKt;
|
import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||||
import awais.instagrabber.utils.Utils;
|
import awais.instagrabber.utils.Utils;
|
||||||
|
import awais.instagrabber.utils.TextUtils;
|
||||||
import awais.instagrabber.webservices.CommentService;
|
import awais.instagrabber.webservices.CommentService;
|
||||||
import awais.instagrabber.webservices.GraphQLRepository;
|
import awais.instagrabber.webservices.GraphQLRepository;
|
||||||
import awais.instagrabber.webservices.ServiceCallback;
|
import awais.instagrabber.webservices.ServiceCallback;
|
||||||
@ -77,7 +78,7 @@ public class CommentsViewerViewModel extends ViewModel {
|
|||||||
comments = mergeList(rootList, comments);
|
comments = mergeList(rootList, comments);
|
||||||
}
|
}
|
||||||
rootCursor = result.getNextMinId();
|
rootCursor = result.getNextMinId();
|
||||||
rootHasNext = result.getHasMoreComments();
|
rootHasNext = !TextUtils.isEmpty(rootCursor);
|
||||||
rootList.postValue(Resource.success(comments));
|
rootList.postValue(Resource.success(comments));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +234,7 @@ public class CommentsViewerViewModel extends ViewModel {
|
|||||||
final Comment commentModel = getComment(commentsJsonArray.getJSONObject(i).getJSONObject("node"), root);
|
final Comment commentModel = getComment(commentsJsonArray.getJSONObject(i).getJSONObject("node"), root);
|
||||||
builder.add(commentModel);
|
builder.add(commentModel);
|
||||||
}
|
}
|
||||||
final Object result = root ? new CommentsFetchResponse(count, endCursor, builder.build(), hasNextPage)
|
final Object result = root ? new CommentsFetchResponse(count, endCursor, builder.build())
|
||||||
: new ChildCommentsFetchResponse(count, endCursor, builder.build(), hasNextPage);
|
: new ChildCommentsFetchResponse(count, endCursor, builder.build(), hasNextPage);
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
callback.onSuccess(result);
|
callback.onSuccess(result);
|
||||||
|
@ -70,11 +70,11 @@ public class CommentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fetchComments(@NonNull final String mediaId,
|
public void fetchComments(@NonNull final String mediaId,
|
||||||
final String maxId,
|
final String minId,
|
||||||
@NonNull final ServiceCallback<CommentsFetchResponse> callback) {
|
@NonNull final ServiceCallback<CommentsFetchResponse> callback) {
|
||||||
final Map<String, String> form = new HashMap<>();
|
final Map<String, String> form = new HashMap<>();
|
||||||
form.put("can_support_threading", "true");
|
form.put("can_support_threading", "true");
|
||||||
if (maxId != null) form.put("max_id", maxId);
|
if (minId != null) form.put("min_id", minId);
|
||||||
final Call<CommentsFetchResponse> request = repository.fetchComments(mediaId, form);
|
final Call<CommentsFetchResponse> request = repository.fetchComments(mediaId, form);
|
||||||
request.enqueue(new Callback<CommentsFetchResponse>() {
|
request.enqueue(new Callback<CommentsFetchResponse>() {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user