From 392ea8ee9b62b8bcf2c03399d56e47a0394758d4 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Wed, 29 May 2024 16:51:12 -0400 Subject: Fix user posts not loading by a stupid workaround. --- .../docilealligator/infinityforreddit/apis/RedditAPI.java | 13 +++++++++---- .../infinityforreddit/post/PostPagingSource.java | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java index 9db3669e..78bb8bb4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -5,6 +5,7 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.Map; import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.utils.APIUtils; import okhttp3.MultipartBody; import okhttp3.RequestBody; import retrofit2.Call; @@ -15,6 +16,7 @@ import retrofit2.http.Field; import retrofit2.http.FieldMap; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; +import retrofit2.http.Header; import retrofit2.http.HeaderMap; import retrofit2.http.Multipart; import retrofit2.http.POST; @@ -282,10 +284,13 @@ public interface RedditAPI { ListenableFuture> getSubredditBestPostsListenableFuture(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType, @Query("t") SortType.Time sortTime, @Query("after") String lastItem); - @GET("user/{username}/{where}.json?&type=links&raw_json=1&limit=100") - ListenableFuture> getUserPostsOauthListenableFuture(@Path("username") String username, @Path("where") String where, - @Query("after") String lastItem, @Query("sort") SortType.Type sortType, - @Query("t") SortType.Time sortTime, @HeaderMap Map headers); + @GET("user/{username}/{where}.json?type=links&raw_json=1&limit=100") + ListenableFuture> getUserPostsOauthListenableFuture(@Header(APIUtils.AUTHORIZATION_KEY) String authorization, + @Path("username") String username, + @Path("where") String where, + @Query("after") String lastItem, + @Query("sort") SortType.Type sortType, + @Query("t") SortType.Time sortTime); @GET("user/{username}/submitted.json?raw_json=1&limit=100") ListenableFuture> getUserPostsListenableFuture(@Path("username") String username, @Query("after") String lastItem, 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 2d5191a4..7c256d59 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java @@ -257,8 +257,8 @@ public class PostPagingSource extends ListenableFuturePagingSource userPosts = api.getUserPostsListenableFuture(subredditOrUserName, loadParams.getKey(), sortType.getType(), sortType.getTime()); } else { - userPosts = api.getUserPostsOauthListenableFuture(subredditOrUserName, userWhere, loadParams.getKey(), sortType.getType(), - sortType.getTime(), APIUtils.getOAuthHeader(accessToken)); + userPosts = api.getUserPostsOauthListenableFuture(APIUtils.AUTHORIZATION_BASE + accessToken, + subredditOrUserName, userWhere, loadParams.getKey(), sortType.getType(), sortType.getTime()); } ListenableFuture> pageFuture = Futures.transform(userPosts, this::transformData, executor); -- cgit v1.2.3