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.
This commit is contained in:
parent
7c59b700da
commit
b7b646f03a
|
@ -79,7 +79,10 @@ public abstract class BaseAccountListFragment extends RecyclerFragment<BaseAccou
|
||||||
if(refreshing){
|
if(refreshing){
|
||||||
relationships.clear();
|
relationships.clear();
|
||||||
}
|
}
|
||||||
|
if(!d.isEmpty() && !d.get(0).account.reloadWhenClicked){
|
||||||
loadRelationships(d);
|
loadRelationships(d);
|
||||||
|
}
|
||||||
|
|
||||||
super.onDataLoaded(d, more);
|
super.onDataLoaded(d, more);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +245,12 @@ public abstract class BaseAccountListFragment extends RecyclerFragment<BaseAccou
|
||||||
public void bindRelationship(){
|
public void bindRelationship(){
|
||||||
Relationship rel=relationships.get(item.account.id);
|
Relationship rel=relationships.get(item.account.id);
|
||||||
if(rel==null || AccountSessionManager.getInstance().isSelf(accountID, item.account)){
|
if(rel==null || AccountSessionManager.getInstance().isSelf(accountID, item.account)){
|
||||||
|
if(item.account.reloadWhenClicked){
|
||||||
|
button.setVisibility(View.VISIBLE);
|
||||||
|
button.setText(R.string.button_follow);
|
||||||
|
} else {
|
||||||
button.setVisibility(View.GONE);
|
button.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
button.setVisibility(View.VISIBLE);
|
button.setVisibility(View.VISIBLE);
|
||||||
UiUtils.setRelationshipToActionButton(rel, button);
|
UiUtils.setRelationshipToActionButton(rel, button);
|
||||||
|
|
|
@ -759,6 +759,33 @@ public class UiUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performAccountAction(Activity activity, Account account, String accountID, Relationship relationship, Button button, Consumer<Boolean> progressCallback, Consumer<Relationship> resultCallback) {
|
public static void performAccountAction(Activity activity, Account account, String accountID, Relationship relationship, Button button, Consumer<Boolean> progressCallback, Consumer<Relationship> 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) {
|
if (relationship.blocking) {
|
||||||
confirmToggleBlockUser(activity, accountID, account, true, resultCallback);
|
confirmToggleBlockUser(activity, accountID, account, true, resultCallback);
|
||||||
}else if(relationship.muting){
|
}else if(relationship.muting){
|
||||||
|
|
Loading…
Reference in New Issue