From 27e84d18f6d6cbfc47f2ec370eb7f6fa8432dde3 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Mon, 14 Aug 2023 23:36:29 -0400 Subject: Probably fixed key reuse in PostPagingSource caused by NSFW posts being disabled by Reddit. --- .../ml/docilealligator/infinityforreddit/post/PostPagingSource.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java index bd2b51e8..86216dcb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java @@ -58,6 +58,7 @@ public class PostPagingSource extends ListenableFuturePagingSource private String userWhere; private String multiRedditPath; private LinkedHashSet postLinkedHashSet; + private String previousLastItem; PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName, SharedPreferences sharedPreferences, @@ -188,6 +189,11 @@ public class PostPagingSource extends ListenableFuturePagingSource return new LoadResult.Error<>(new Exception("Error parsing posts")); } else { int currentPostsSize = postLinkedHashSet.size(); + if (lastItem != null && lastItem.equals(previousLastItem)) { + lastItem = null; + } + previousLastItem = lastItem; + postLinkedHashSet.addAll(newPosts); if (currentPostsSize == postLinkedHashSet.size()) { return new LoadResult.Page<>(new ArrayList<>(), null, lastItem); -- cgit v1.2.3