Search in sources :

Example 1 with ActiveDialogStorage

use of im.actor.core.modules.messaging.router.entity.ActiveDialogStorage in project actor-platform by actorapp.

the class RouterActor method preStart.

@Override
public void preStart() {
    super.preStart();
    conversationStates = context().getMessagesModule().getConversationStates().getEngine();
    // 
    // Loading Active Dialogs
    // 
    activeDialogStorage = new ActiveDialogStorage();
    byte[] data = context().getStorageModule().getBlobStorage().loadItem(AbsModule.BLOB_DIALOGS_ACTIVE);
    if (data != null) {
        try {
            activeDialogStorage = new ActiveDialogStorage(data);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (!activeDialogStorage.isLoaded()) {
        api(new RequestLoadGroupedDialogs(ApiSupportConfiguration.OPTIMIZATIONS)).chain(r -> updates().applyRelatedData(r.getUsers(), r.getGroups())).chain(r -> updates().loadRequiredPeers(r.getUserPeers(), r.getGroupPeers())).then(r -> {
            boolean showArchived = false;
            boolean showInvite = false;
            if (r.showArchived() != null) {
                showArchived = r.showArchived();
            }
            if (r.showInvite() != null) {
                showInvite = r.showInvite();
            }
            onActiveDialogsChanged(r.getDialogs(), showArchived, showInvite);
            context().getConductor().getConductor().onDialogsLoaded();
        });
    } else {
        notifyActiveDialogsVM();
        context().getConductor().getConductor().onDialogsLoaded();
    }
}
Also used : DialogsInt(im.actor.core.modules.messaging.dialogs.DialogsInt) RouterDifferenceStart(im.actor.core.modules.messaging.router.entity.RouterDifferenceStart) ModuleContext(im.actor.core.modules.ModuleContext) ApiMessageReaction(im.actor.core.api.ApiMessageReaction) UpdateChatGroupsChanged(im.actor.core.api.updates.UpdateChatGroupsChanged) UpdateMessage(im.actor.core.api.updates.UpdateMessage) ActiveDialogStorage(im.actor.core.modules.messaging.router.entity.ActiveDialogStorage) RouterApplyChatHistory(im.actor.core.modules.messaging.router.entity.RouterApplyChatHistory) RouterApplyDialogsHistory(im.actor.core.modules.messaging.router.entity.RouterApplyDialogsHistory) Avatar(im.actor.core.entity.Avatar) JavaUtil(im.actor.core.util.JavaUtil) RouterMessageUpdate(im.actor.core.modules.messaging.router.entity.RouterMessageUpdate) DialogSmall(im.actor.core.viewmodel.DialogSmall) TextContent(im.actor.core.entity.content.TextContent) ApiDialogGroup(im.actor.core.api.ApiDialogGroup) EntityConverter.convert(im.actor.core.entity.EntityConverter.convert) ApiSupportConfiguration(im.actor.core.modules.api.ApiSupportConfiguration) UpdateMessageReadByMe(im.actor.core.api.updates.UpdateMessageReadByMe) RequestLoadGroupedDialogs(im.actor.core.api.rpc.RequestLoadGroupedDialogs) UpdateReactionsUpdate(im.actor.core.api.updates.UpdateReactionsUpdate) Void(im.actor.runtime.actors.messages.Void) DialogHistory(im.actor.core.modules.messaging.history.entity.DialogHistory) RouterDifferenceEnd(im.actor.core.modules.messaging.router.entity.RouterDifferenceEnd) Reaction(im.actor.core.entity.Reaction) AssertUtils.assertTrue(im.actor.core.util.AssertUtils.assertTrue) RouterConversationVisible(im.actor.core.modules.messaging.router.entity.RouterConversationVisible) List(java.util.List) ModuleActor(im.actor.core.modules.ModuleActor) RouterOutgoingSent(im.actor.core.modules.messaging.router.entity.RouterOutgoingSent) ArrayListDialogSmall(im.actor.core.viewmodel.generics.ArrayListDialogSmall) CursorReceiverActor(im.actor.core.modules.messaging.actions.CursorReceiverActor) UpdateMessageDelete(im.actor.core.api.updates.UpdateMessageDelete) UpdateChatDropCache(im.actor.core.api.updates.UpdateChatDropCache) UpdateMessageContentChanged(im.actor.core.api.updates.UpdateMessageContentChanged) Peer(im.actor.core.entity.Peer) MessageState(im.actor.core.entity.MessageState) RouterChangedContent(im.actor.core.modules.messaging.router.entity.RouterChangedContent) Message(im.actor.core.entity.Message) UpdateMessageReceived(im.actor.core.api.updates.UpdateMessageReceived) RouterAppHidden(im.actor.core.modules.messaging.router.entity.RouterAppHidden) Promise(im.actor.runtime.promise.Promise) RouterResetChat(im.actor.core.modules.messaging.router.entity.RouterResetChat) UpdateChatClear(im.actor.core.api.updates.UpdateChatClear) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ConversationState(im.actor.core.entity.ConversationState) AbsModule(im.actor.core.modules.AbsModule) User(im.actor.core.entity.User) RouterAppVisible(im.actor.core.modules.messaging.router.entity.RouterAppVisible) UpdateMessageSent(im.actor.core.api.updates.UpdateMessageSent) UpdateMessageRead(im.actor.core.api.updates.UpdateMessageRead) ListEngine(im.actor.runtime.storage.ListEngine) PeerType(im.actor.core.entity.PeerType) AbsContent(im.actor.core.entity.content.AbsContent) IOException(java.io.IOException) Group(im.actor.core.entity.Group) RouterConversationHidden(im.actor.core.modules.messaging.router.entity.RouterConversationHidden) RouterOutgoingError(im.actor.core.modules.messaging.router.entity.RouterOutgoingError) CursorReaderActor(im.actor.core.modules.messaging.actions.CursorReaderActor) RouterPeersChanged(im.actor.core.modules.messaging.router.entity.RouterPeersChanged) RouterMessageOnlyActive(im.actor.core.modules.messaging.router.entity.RouterMessageOnlyActive) RouterNewMessages(im.actor.core.modules.messaging.router.entity.RouterNewMessages) RouterOutgoingMessage(im.actor.core.modules.messaging.router.entity.RouterOutgoingMessage) SenderActor(im.actor.core.modules.messaging.actions.SenderActor) DialogGroup(im.actor.core.viewmodel.DialogGroup) ActiveDialogGroup(im.actor.core.modules.messaging.router.entity.ActiveDialogGroup) RouterDeletedMessages(im.actor.core.modules.messaging.router.entity.RouterDeletedMessages) ContentDescription(im.actor.core.entity.ContentDescription) Log(im.actor.runtime.Log) KeyValueEngine(im.actor.runtime.storage.KeyValueEngine) UpdateChatDelete(im.actor.core.api.updates.UpdateChatDelete) ApiDialogShort(im.actor.core.api.ApiDialogShort) Update(im.actor.core.network.parser.Update) ActiveDialogStorage(im.actor.core.modules.messaging.router.entity.ActiveDialogStorage) RequestLoadGroupedDialogs(im.actor.core.api.rpc.RequestLoadGroupedDialogs) IOException(java.io.IOException)

Aggregations

ApiDialogGroup (im.actor.core.api.ApiDialogGroup)1 ApiDialogShort (im.actor.core.api.ApiDialogShort)1 ApiMessageReaction (im.actor.core.api.ApiMessageReaction)1 RequestLoadGroupedDialogs (im.actor.core.api.rpc.RequestLoadGroupedDialogs)1 UpdateChatClear (im.actor.core.api.updates.UpdateChatClear)1 UpdateChatDelete (im.actor.core.api.updates.UpdateChatDelete)1 UpdateChatDropCache (im.actor.core.api.updates.UpdateChatDropCache)1 UpdateChatGroupsChanged (im.actor.core.api.updates.UpdateChatGroupsChanged)1 UpdateMessage (im.actor.core.api.updates.UpdateMessage)1 UpdateMessageContentChanged (im.actor.core.api.updates.UpdateMessageContentChanged)1 UpdateMessageDelete (im.actor.core.api.updates.UpdateMessageDelete)1 UpdateMessageRead (im.actor.core.api.updates.UpdateMessageRead)1 UpdateMessageReadByMe (im.actor.core.api.updates.UpdateMessageReadByMe)1 UpdateMessageReceived (im.actor.core.api.updates.UpdateMessageReceived)1 UpdateMessageSent (im.actor.core.api.updates.UpdateMessageSent)1 UpdateReactionsUpdate (im.actor.core.api.updates.UpdateReactionsUpdate)1 Avatar (im.actor.core.entity.Avatar)1 ContentDescription (im.actor.core.entity.ContentDescription)1 ConversationState (im.actor.core.entity.ConversationState)1 EntityConverter.convert (im.actor.core.entity.EntityConverter.convert)1