From b7b646f03aa55f3fe7b4217d851c6ecb7e361441 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Tue, 18 Apr 2023 15:09:14 -0300 Subject: [PATCH] feat: add follow button on remote follower lists NOTE: This doesn't actually load remote relationships, so its always going to be in the "follow" state. --- .../account_list/BaseAccountListFragment.java | 12 +++++++-- .../android/ui/utils/UiUtils.java | 27 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BaseAccountListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BaseAccountListFragment.java index 357540ab5..36f9913d2 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BaseAccountListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BaseAccountListFragment.java @@ -79,7 +79,10 @@ public abstract class BaseAccountListFragment extends RecyclerFragment progressCallback, Consumer resultCallback) { + if(relationship == null){ + UiUtils.lookupAccount(button.getContext(), account, accountID, null, account1 -> { + if(account1 == null){ + return; + } + progressCallback.accept(true); + new SetAccountFollowed(account1.id, true, true, false) + .setCallback(new Callback<>(){ + @Override + public void onSuccess(Relationship result){ + resultCallback.accept(result); + progressCallback.accept(false); + if(!result.following && !result.requested){ + E.post(new RemoveAccountPostsEvent(accountID, account.id, true)); + } + } + + @Override + public void onError(ErrorResponse error){ + error.showToast(activity); + progressCallback.accept(false); + } + }) + .exec(accountID); + }); + return; + } if (relationship.blocking) { confirmToggleBlockUser(activity, accountID, account, true, resultCallback); }else if(relationship.muting){