Browse Source

Fix comment replies cursor

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
bcec6d373c
  1. 9
      app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java
  2. 2
      app/src/main/java/awais/instagrabber/webservices/CommentService.java

9
app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java

@ -185,8 +185,9 @@ public class CommentsViewerViewModel extends ViewModel {
list = getPrevList(replyList);
}
replyList.postValue(Resource.loading(list));
if (isLoggedIn.getValue()) {
commentService.fetchChildComments(postId, commentId, rootCursor, rcb);
final Boolean isLoggedInValue = isLoggedIn.getValue();
if (isLoggedInValue != null && isLoggedInValue) {
commentService.fetchChildComments(postId, commentId, repliesCursor, rcb);
return;
}
final Call<String> request = graphQLService.fetchComments(commentId, false, repliesCursor);
@ -224,8 +225,8 @@ public class CommentsViewerViewModel extends ViewModel {
builder.add(commentModel);
}
callback.onSuccess(root ?
new CommentsFetchResponse(count, endCursor, builder.build()) :
new ChildCommentsFetchResponse(count, endCursor, builder.build()));
new CommentsFetchResponse(count, endCursor, builder.build()) :
new ChildCommentsFetchResponse(count, endCursor, builder.build()));
} catch (Exception e) {
Log.e(TAG, "onResponse", e);
callback.onFailure(e);

2
app/src/main/java/awais/instagrabber/webservices/CommentService.java

@ -79,7 +79,6 @@ public class CommentService extends BaseService {
request.enqueue(new Callback<CommentsFetchResponse>() {
@Override
public void onResponse(@NonNull final Call<CommentsFetchResponse> call, @NonNull final Response<CommentsFetchResponse> response) {
if (callback == null) return;
final CommentsFetchResponse cfr = response.body();
if (cfr == null) callback.onFailure(new Exception("response is empty"));
callback.onSuccess(cfr);
@ -102,7 +101,6 @@ public class CommentService extends BaseService {
request.enqueue(new Callback<ChildCommentsFetchResponse>() {
@Override
public void onResponse(@NonNull final Call<ChildCommentsFetchResponse> call, @NonNull final Response<ChildCommentsFetchResponse> response) {
if (callback == null) return;
final ChildCommentsFetchResponse cfr = response.body();
if (cfr == null) callback.onFailure(new Exception("response is empty"));
callback.onSuccess(cfr);

Loading…
Cancel
Save