From bcec6d373c2fab7a1061d6a230230322a182a289 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Tue, 1 Jun 2021 18:16:54 +0900 Subject: [PATCH] Fix comment replies cursor --- .../instagrabber/viewmodels/CommentsViewerViewModel.java | 9 +++++---- .../awais/instagrabber/webservices/CommentService.java | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java b/app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java index a7e3c52c..431497f0 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/CommentsViewerViewModel.java +++ b/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 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); diff --git a/app/src/main/java/awais/instagrabber/webservices/CommentService.java b/app/src/main/java/awais/instagrabber/webservices/CommentService.java index 2a0b72ea..70d00375 100644 --- a/app/src/main/java/awais/instagrabber/webservices/CommentService.java +++ b/app/src/main/java/awais/instagrabber/webservices/CommentService.java @@ -79,7 +79,6 @@ public class CommentService extends BaseService { request.enqueue(new Callback() { @Override public void onResponse(@NonNull final Call call, @NonNull final Response 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() { @Override public void onResponse(@NonNull final Call call, @NonNull final Response response) { - if (callback == null) return; final ChildCommentsFetchResponse cfr = response.body(); if (cfr == null) callback.onFailure(new Exception("response is empty")); callback.onSuccess(cfr);