From 7877001533688c75e7b59f150f0100228e06ea65 Mon Sep 17 00:00:00 2001 From: Balazs Toldi Date: Sat, 12 Aug 2023 21:02:44 +0200 Subject: [PATCH] Fix bugs related to fetching blocked users --- .../toldi/infinityforlemmy/account/FetchBlockedThings.java | 5 ++++- .../infinityforlemmy/activities/ViewUserDetailActivity.java | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/account/FetchBlockedThings.java b/app/src/main/java/eu/toldi/infinityforlemmy/account/FetchBlockedThings.java index 7bc2b06b..67e1a30d 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/account/FetchBlockedThings.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/account/FetchBlockedThings.java @@ -40,7 +40,10 @@ public class FetchBlockedThings { JSONObject blockedUserJson = blockedUsersJson.getJSONObject(i).getJSONObject("target"); int id = blockedUserJson.getInt("id"); String name = blockedUserJson.getString("name"); - String avatar = blockedUserJson.getString("avatar"); + String avatar = ""; + if (blockedUserJson.has("avatar")) + avatar = blockedUserJson.getString("avatar"); + String qualifiedName = LemmyUtils.actorID2FullName(blockedUserJson.getString("actor_id")); BlockedUserData blockedUserData = new BlockedUserData(id, name, avatar, qualifiedName, accountName); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java index 547d112e..fadb6511 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java @@ -1094,8 +1094,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele mUserData = userData; username = userData.getName(); setupVisibleElements(); - new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData, - () -> mFetchUserInfoSuccess = true).execute(); FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() { @Override @@ -1108,13 +1106,15 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } } isBlocked = false; + invalidateOptionsMenu(); } @Override public void onFetchBlockedThingsFailure() { - } }); + new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData, + () -> mFetchUserInfoSuccess = true).execute(); } @Override