Commit 3a3f6aa3 authored by Thomas's avatar Thomas
Browse files

Fix issue #493 - Crash when adding account to a list from profile

parent 9d8c815a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -875,7 +875,7 @@ public class ProfileActivity extends BaseActivity {
                                                        updateAccount();
                                                        if (isChecked) {
                                                            timelinesVM.addAccountsList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, listsId[which], userIds).observe(ProfileActivity.this, success -> {
                                                                if (!success) {
                                                                if (success == null || !success) {
                                                                    Toasty.error(ProfileActivity.this, getString(R.string.toast_error_add_to_list), Toast.LENGTH_LONG).show();
                                                                }
                                                            });
@@ -886,7 +886,7 @@ public class ProfileActivity extends BaseActivity {
                                        } else {
                                            if (isChecked) {
                                                timelinesVM.addAccountsList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, listsId[which], userIds).observe(ProfileActivity.this, success -> {
                                                    if (!success) {
                                                    if (success == null || !success) {
                                                        Toasty.error(ProfileActivity.this, getString(R.string.toast_error_add_to_list), Toast.LENGTH_LONG).show();
                                                    }
                                                });
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public interface MastodonTimelinesService {
    //Add account in a list
    @FormUrlEncoded
    @POST("lists/{id}/accounts")
    Call<Boolean> addAccountsList(
    Call<Void> addAccountsList(
            @Header("Authorization") String token,
            @Path("id") String id,
            @Field("account_ids[]") List<String> account_ids
+3 −2
Original line number Diff line number Diff line
@@ -843,14 +843,15 @@ public class TimelinesVM extends AndroidViewModel {
        MastodonTimelinesService mastodonTimelinesService = init(instance);
        booleanMutableLiveData = new MutableLiveData<>();
        new Thread(() -> {
            Call<Boolean> addAccountsListCall = mastodonTimelinesService.addAccountsList(token, listId, accountIds);
            Call<Void> addAccountsListCall = mastodonTimelinesService.addAccountsList(token, listId, accountIds);
            Boolean reply = null;
            if (addAccountsListCall != null) {
                try {
                    Response<Boolean> response = addAccountsListCall.execute();
                    Response<Void> response = addAccountsListCall.execute();
                    reply = response.isSuccessful();
                } catch (Exception e) {
                    e.printStackTrace();
                    reply = false;
                }
            }
            Handler mainHandler = new Handler(Looper.getMainLooper());