use of im.actor.core.api.rpc.RequestRemoveContact in project actor-platform by actorapp.
the class ContactsModule method removeContact.
public Command<Boolean> removeContact(final int uid) {
return callback -> {
User user = users().getValue(uid);
if (user == null) {
runOnUiThread(() -> callback.onError(new RpcInternalException()));
return;
}
request(new RequestRemoveContact(uid, user.getAccessHash()), new RpcCallback<ResponseSeq>() {
@Override
public void onResult(ResponseSeq response) {
ArrayList<Integer> uids = new ArrayList<>();
uids.add(uid);
SeqUpdate update = new SeqUpdate(response.getSeq(), response.getState(), UpdateContactsRemoved.HEADER, new UpdateContactsRemoved(uids).toByteArray());
updates().onUpdateReceived(update);
runOnUiThread(() -> callback.onResult(true));
}
@Override
public void onError(RpcException e) {
runOnUiThread(() -> callback.onError(new RpcInternalException()));
}
});
};
}
Aggregations