From 3b5852d1e4cfa3a447a0e0aa7df9318a5cce4dd0 Mon Sep 17 00:00:00 2001 From: Balazs Toldi Date: Thu, 27 Jul 2023 07:49:46 +0200 Subject: [PATCH] Fix bug when progress indicator is present on the comments page, even after loading all the comments Signed-off-by: Balazs Toldi --- .../adapters/CommentsRecyclerViewAdapter.java | 10 ++++++++++ .../fragments/ViewPostDetailFragment.java | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/eu/toldi/infinityforlemmy/adapters/CommentsRecyclerViewAdapter.java index 3ae83418..bb6251f9 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/adapters/CommentsRecyclerViewAdapter.java @@ -856,6 +856,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter 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) newComments; + int sizeBefore = mVisibleComments.size(); mVisibleComments.addAll(comments); for (int i = 0; i < comments.size(); i++) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java b/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java index 0232b13d..ec27cb6a 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java @@ -1450,6 +1450,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic @Override public void onFetchCommentSuccess(ArrayList expandedComments, Integer parentId, ArrayList 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 expandedComments, Integer parentId, ArrayList children) {