mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 19:08:24 +01:00
Fix bug with post detail refreshing
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
This commit is contained in:
parent
258ff290bb
commit
c756342ce6
@ -24,6 +24,9 @@ public interface LemmyAPI {
|
||||
@GET("api/v3/community")
|
||||
Call<String> communityInfo(@Query("name") String name, @Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/post")
|
||||
Call<String> postInfo(@Query("id") Integer postID, @Query("comment_id") Integer comment_id, @Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/user")
|
||||
ListenableFuture<Response<String>> getUserPosts(
|
||||
@Query("username") String username,
|
||||
|
@ -6,8 +6,8 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -17,11 +17,9 @@ public class FetchPost {
|
||||
public static void fetchPost(Executor executor, Handler handler, Retrofit retrofit, String id, String accessToken,
|
||||
FetchPostListener fetchPostListener) {
|
||||
Call<String> postCall;
|
||||
if (accessToken == null) {
|
||||
postCall = retrofit.create(RedditAPI.class).getPost(id);
|
||||
} else {
|
||||
postCall = retrofit.create(RedditAPI.class).getPostOauth(id, APIUtils.getOAuthHeader(accessToken));
|
||||
}
|
||||
// Use LemmyAPI.postInfo() instead of RedditAPI.getPost()
|
||||
postCall = retrofit.create(LemmyAPI.class).postInfo(Integer.parseInt(id), null, accessToken);
|
||||
|
||||
postCall.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
|
@ -98,13 +98,13 @@ public class ParsePost {
|
||||
|
||||
executor.execute(() -> {
|
||||
try {
|
||||
JSONArray allData = new JSONArray(response).getJSONObject(0).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||
JSONObject allData = new JSONObject(response).getJSONObject("post_view");
|
||||
if (allData.length() == 0) {
|
||||
handler.post(parsePostListener::onParsePostFail);
|
||||
return;
|
||||
}
|
||||
JSONObject data = allData.getJSONObject(0).getJSONObject(JSONUtils.DATA_KEY);
|
||||
Post post = parseBasicData(data);
|
||||
|
||||
Post post = parseBasicData(allData);
|
||||
handler.post(() -> parsePostListener.onParsePostSuccess(post));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user