Fix bug when progress indicator is present on the comments page, even after loading all the comments

Signed-off-by: Balazs Toldi <balazs@toldi.eu>
This commit is contained in:
Balazs Toldi 2023-07-27 07:49:46 +02:00
parent 0fa2da6ffa
commit 3b5852d1e4
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 12 additions and 4 deletions

View File

@ -856,6 +856,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
}
List<Comment> newComments = new ArrayList<>();
for (int i = 0; i < comments.size(); i++) {
if (loadedComments.contains(comments.get(i).getId())) {
continue;
}
newComments.add(comments.get(i));
loadedComments.add(comments.get(i).getId());
}
comments = (ArrayList<Comment>) newComments;
int sizeBefore = mVisibleComments.size();
mVisibleComments.addAll(comments);
for (int i = 0; i < comments.size(); i++) {

View File

@ -1450,6 +1450,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Override
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments,
Integer parentId, ArrayList<Integer> children) {
isFetchingComments = false;
ViewPostDetailFragment.this.children = children;
pages_loaded++;
comments = expandedComments;
@ -1508,8 +1509,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (changeRefreshState) {
isRefreshing = false;
}
isFetchingComments = false;
}
@Override
@ -1535,8 +1534,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
isLoadingMoreChildren = true;
Retrofit retrofit = mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit;
FetchComment.fetchComments(mExecutor, new Handler(), retrofit, mAccessToken,
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken,
mPost.getId(), null, sortType, mExpandChildren, pages_loaded + 1, new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {