fix confirm unfollow

This commit is contained in:
sk 2023-10-16 00:11:47 +02:00
parent d5d06af614
commit 98e003437c
1 changed files with 24 additions and 17 deletions

View File

@ -804,11 +804,12 @@ public class UiUtils {
} else if (relationship.muting) { } else if (relationship.muting) {
confirmToggleMuteUser(activity, accountID, account, true, resultCallback); confirmToggleMuteUser(activity, accountID, account, true, resultCallback);
} else { } else {
Runnable action=()->{
progressCallback.accept(true); progressCallback.accept(true);
new SetAccountFollowed(account.id, !relationship.following && !relationship.requested, true, false) new SetAccountFollowed(account.id, !relationship.following && !relationship.requested, true)
.setCallback(new Callback<>() { .setCallback(new Callback<>(){
@Override @Override
public void onSuccess(Relationship result) { public void onSuccess(Relationship result){
resultCallback.accept(result); resultCallback.accept(result);
progressCallback.accept(false); progressCallback.accept(false);
if(!result.following && !result.requested){ if(!result.following && !result.requested){
@ -817,12 +818,18 @@ public class UiUtils {
} }
@Override @Override
public void onError(ErrorResponse error) { public void onError(ErrorResponse error){
error.showToast(activity); error.showToast(activity);
progressCallback.accept(false); progressCallback.accept(false);
} }
}) })
.exec(accountID); .exec(accountID);
};
if(relationship.following && GlobalUserPreferences.confirmUnfollow){
showConfirmationAlert(activity, null, activity.getString(R.string.unfollow_confirmation, account.getDisplayUsername()), activity.getString(R.string.unfollow), R.drawable.ic_fluent_person_delete_24_regular, action);
}else{
action.run();
}
} }
} }