use of im.actor.core.api.rpc.ResponseLoadArchived 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));
}
use of im.actor.core.api.rpc.ResponseLoadArchived in project actor-platform by actorapp.
the class JsFacade method loadArchivedDialogs.
@UsedByApp
private JsPromise loadArchivedDialogs(final boolean init) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.loadArchivedDialogs(init, new RpcCallback<ResponseLoadArchived>() {
@Override
public void onResult(ResponseLoadArchived response) {
JsArray<JsDialogShort> res = JsArray.createArray().cast();
for (ApiDialog d : response.getDialogs()) {
res.push(JsDialogShort.create(messenger.buildPeerInfo(EntityConverter.convert(d.getPeer())), d.getUnreadCount()));
}
Log.d(TAG, "loadArchivedDialogs:result");
resolve(res);
}
@Override
public void onError(RpcException e) {
Log.d(TAG, "loadArchivedDialogs:error");
reject(e.getMessage());
}
});
}
});
}
Aggregations