use of im.actor.core.api.ApiDialog 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());
}
});
}
});
}
use of im.actor.core.api.ApiDialog in project actor-platform by actorapp.
the class DialogsHistoryActor method onLoadedMore.
private void onLoadedMore(List<ApiDialog> rawDialogs) {
final ArrayList<DialogHistory> dialogs = new ArrayList<>();
long maxLoadedDate = Long.MAX_VALUE;
for (ApiDialog dialog : rawDialogs) {
dialogs.add(new DialogHistory(convert(dialog.getPeer()), dialog.getUnreadCount(), dialog.getSortDate(), dialog.getRid(), dialog.getDate(), dialog.getSenderUid(), AbsContent.fromMessage(dialog.getMessage()), dialog.getState() == ApiMessageState.READ, dialog.getState() == ApiMessageState.RECEIVED));
maxLoadedDate = Math.min(dialog.getSortDate(), maxLoadedDate);
}
if (dialogs.size() > 0) {
final long finalMaxLoadedDate = maxLoadedDate;
context().getMessagesModule().getRouter().onDialogsHistoryLoaded(dialogs).then((v) -> {
if (dialogs.size() < LIMIT) {
markAsLoaded();
} else {
markAsSliceLoaded(finalMaxLoadedDate);
}
});
} else {
markAsLoaded();
}
}
Aggregations