Search in sources :

Example 1 with RequestLoadArchived

use of im.actor.core.api.rpc.RequestLoadArchived in project actor-platform by actorapp.

the class ArchivedDialogsActor method onLoadMore.

private void onLoadMore(boolean init, RpcCallback<ResponseLoadArchived> callback) {
    if (init || isLoading) {
        //
        if (lastCallback != null) {
            lastCallback.onError(new RpcException(TAG, 0, "callback replaced", false, null));
        }
    }
    lastCallback = callback;
    if (isLoading && !init) {
        return;
    }
    if (init) {
        if (lastRequest != -1) {
            cancelRequest(lastRequest);
        }
        nextOffset = null;
    }
    isLoading = true;
    Log.d(TAG, "Loading archived dialogs");
    api(new RequestLoadArchived(nextOffset, LIMIT, ApiSupportConfiguration.OPTIMIZATIONS)).chain(r -> updates().applyRelatedData(r.getUsers(), r.getGroups())).chain(r -> updates().loadRequiredPeers(r.getUserPeers(), r.getGroupPeers())).then(r -> onLoadedMore(r)).failure(e -> lastCallback.onError((RpcException) e));
}
Also used : RequestLoadArchived(im.actor.core.api.rpc.RequestLoadArchived) ApiSupportConfiguration(im.actor.core.modules.api.ApiSupportConfiguration) ModuleContext(im.actor.core.modules.ModuleContext) ModuleActor(im.actor.core.modules.ModuleActor) Consumer(im.actor.runtime.function.Consumer) Void(im.actor.runtime.actors.messages.Void) RpcCallback(im.actor.core.network.RpcCallback) Log(im.actor.runtime.Log) ResponseLoadArchived(im.actor.core.api.rpc.ResponseLoadArchived) RpcException(im.actor.core.network.RpcException) RpcException(im.actor.core.network.RpcException) RequestLoadArchived(im.actor.core.api.rpc.RequestLoadArchived)

Aggregations

RequestLoadArchived (im.actor.core.api.rpc.RequestLoadArchived)1 ResponseLoadArchived (im.actor.core.api.rpc.ResponseLoadArchived)1 ModuleActor (im.actor.core.modules.ModuleActor)1 ModuleContext (im.actor.core.modules.ModuleContext)1 ApiSupportConfiguration (im.actor.core.modules.api.ApiSupportConfiguration)1 RpcCallback (im.actor.core.network.RpcCallback)1 RpcException (im.actor.core.network.RpcException)1 Log (im.actor.runtime.Log)1 Void (im.actor.runtime.actors.messages.Void)1 Consumer (im.actor.runtime.function.Consumer)1