use of im.actor.core.modules.messaging.history.entity.DialogHistory in project actor-platform by actorapp.
the class RouterActor method onDialogHistoryLoaded.
//
// History Messages
//
private Promise<Void> onDialogHistoryLoaded(List<DialogHistory> dialogs) {
for (DialogHistory d : dialogs) {
ConversationState state = conversationStates.getValue(d.getPeer().getUnuqueId());
if (d.getUnreadCount() > 0) {
state = state.changeCounter(d.getUnreadCount()).changeInMaxDate(d.getDate());
}
if (d.isRead()) {
state = state.changeOutReadDate(d.getDate()).changeOutReceiveDate(d.getDate());
} else if (d.isReceived()) {
state = state.changeOutReceiveDate(d.getDate());
}
conversationStates.addOrUpdateItem(state);
}
return getDialogsRouter().onHistoryLoaded(dialogs);
}
use of im.actor.core.modules.messaging.history.entity.DialogHistory in project actor-platform by actorapp.
the class DialogsActor method onHistoryLoaded.
@Verified
private Promise<Void> onHistoryLoaded(List<DialogHistory> history) {
ArrayList<Dialog> updated = new ArrayList<Dialog>();
for (DialogHistory dialogHistory : history) {
// Ignore already available dialogs
if (dialogs.getValue(dialogHistory.getPeer().getUnuqueId()) != null) {
continue;
}
PeerDesc peerDesc = buildPeerDesc(dialogHistory.getPeer());
if (peerDesc == null) {
continue;
}
ContentDescription description = ContentDescription.fromContent(dialogHistory.getContent());
DialogBuilder builder = new DialogBuilder().setPeer(dialogHistory.getPeer()).setDialogTitle(peerDesc.getTitle()).setDialogAvatar(peerDesc.getAvatar()).setSortKey(dialogHistory.getSortDate()).setRid(dialogHistory.getRid()).setTime(dialogHistory.getDate()).setMessageType(description.getContentType()).setText(description.getText()).setSenderId(dialogHistory.getSenderId()).setRelatedUid(description.getRelatedUser()).setUnreadCount(dialogHistory.getUnreadCount());
if (dialogHistory.isRead()) {
builder.updateKnownReadDate(dialogHistory.getDate());
builder.updateKnownReceiveDate(dialogHistory.getDate());
} else if (dialogHistory.isReceived()) {
builder.updateKnownReceiveDate(dialogHistory.getDate());
}
updated.add(builder.createDialog());
}
addOrUpdateItems(updated);
updateSearch(updated);
notifyState(true);
return Promise.success(null);
}
use of im.actor.core.modules.messaging.history.entity.DialogHistory 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