userlist bug fix

This commit is contained in:
nuclearfog 2023-03-15 23:04:12 +01:00
parent 33eae0dba2
commit 161ced4c7b
No known key found for this signature in database
GPG Key ID: 03488A185C476379
5 changed files with 18 additions and 9 deletions

View File

@ -453,9 +453,8 @@ public interface Connection {
* delete an userlist
*
* @param id ID of the list
* @return removed userlist
*/
UserList deleteUserlist(long id) throws ConnectionException;
void deleteUserlist(long id) throws ConnectionException;
/**
* return userlists an user is owning or following

View File

@ -660,9 +660,12 @@ public class Mastodon implements Connection {
@Override
public UserList deleteUserlist(long id) throws MastodonException {
public void deleteUserlist(long id) throws MastodonException {
try {
return createUserlist(delete(ENDPOINT_USERLIST + id, new ArrayList<>()));
Response response = delete(ENDPOINT_USERLIST + id, new ArrayList<>());
if (response.code() != 200) {
throw new MastodonException(response);
}
} catch (IOException e) {
throw new MastodonException(e);
}

View File

@ -794,10 +794,17 @@ public class TwitterV1 implements Connection {
@Override
public UserList deleteUserlist(long id) throws TwitterException {
public void deleteUserlist(long id) throws TwitterException {
List<String> params = new ArrayList<>();
params.add("list_id=" + id);
return getUserlist(USERLIST_DESTROY, params);
try {
Response response = post(USERLIST_DESTROY, params);
if (response.code() != 200) {
throw new TwitterException(response);
}
} catch (IOException exception) {
throw new TwitterException(exception);
}
}

View File

@ -45,8 +45,8 @@ public class ListAction extends AsyncExecutor<ListAction.ListActionParam, ListAc
return new ListActionResult(ListActionResult.UNFOLLOW, param.id, result, null);
case ListActionParam.DELETE:
result = connection.deleteUserlist(param.id);
return new ListActionResult(ListActionResult.DELETE, param.id, result, null);
connection.deleteUserlist(param.id);
return new ListActionResult(ListActionResult.DELETE, param.id, null, null);
}
} catch (ConnectionException exception) {
return new ListActionResult(ListActionResult.ERROR, param.id, null, exception);

View File

@ -421,7 +421,7 @@ public class UserlistActivity extends AppCompatActivity implements ActivityResul
case ListActionResult.DELETE:
Intent intent = new Intent();
intent.putExtra(RESULT_REMOVED_LIST_ID, result.userlist);
intent.putExtra(RESULT_REMOVED_LIST_ID, result.id);
setResult(RETURN_LIST_REMOVED, intent);
Toast.makeText(getApplicationContext(), R.string.info_list_removed, Toast.LENGTH_SHORT).show();
finish();