Search in sources :

Example 1 with JsTyping

use of im.actor.core.js.entity.JsTyping in project actor-platform by actorapp.

the class JsBindingModule method getTyping.

public JsBindedValue<JsTyping> getTyping(final Peer peer) {
    if (!typing.containsKey(peer)) {
        if (peer.getPeerType() == PeerType.PRIVATE) {
            UserTypingVM userTypingVM = context().getTypingModule().getTyping(peer.getPeerId());
            final JsBindedValue<JsTyping> value = new JsBindedValue<>();
            userTypingVM.getTyping().subscribe((val, valueModel) -> {
                String typingValue = null;
                if (val) {
                    typingValue = messenger.getFormatter().formatTyping("");
                }
                value.changeValue(JsTyping.create(typingValue));
            });
            typing.put(peer, value);
        } else if (peer.getPeerType() == PeerType.GROUP) {
            GroupTypingVM groupTypingVM = context().getTypingModule().getGroupTyping(peer.getPeerId());
            final JsBindedValue<JsTyping> value = new JsBindedValue<>();
            groupTypingVM.getActive().subscribe((val, valueModel) -> {
                if (val.length > 0) {
                    ArrayList<String> names = new ArrayList<>();
                    for (int i : val) {
                        names.add(context().getUsersModule().getUsers().get(i).getName().get());
                    }
                    value.changeValue(JsTyping.create(messenger.getFormatter().formatTyping(names)));
                } else {
                    value.changeValue(JsTyping.create(null));
                }
            });
            typing.put(peer, value);
        } else {
            throw new RuntimeException();
        }
    }
    return typing.get(peer);
}
Also used : UserTypingVM(im.actor.core.viewmodel.UserTypingVM) JsUser(im.actor.core.js.entity.JsUser) ArrayListMediaTrack(im.actor.core.viewmodel.generics.ArrayListMediaTrack) Avatar(im.actor.core.entity.Avatar) JsDialogShort(im.actor.core.js.entity.JsDialogShort) CallMember(im.actor.core.viewmodel.CallMember) DialogSmall(im.actor.core.viewmodel.DialogSmall) GroupTypingVM(im.actor.core.viewmodel.GroupTypingVM) Sticker(im.actor.core.entity.Sticker) ValueModel(im.actor.runtime.mvvm.ValueModel) DocumentContent(im.actor.core.entity.content.DocumentContent) JsContact(im.actor.core.js.entity.JsContact) UserTypingVM(im.actor.core.viewmodel.UserTypingVM) StickerPack(im.actor.core.entity.StickerPack) JsDialogGroup(im.actor.core.js.entity.JsDialogGroup) JsMessage(im.actor.core.js.entity.JsMessage) AppStateVM(im.actor.core.viewmodel.AppStateVM) Peer(im.actor.core.entity.Peer) JsDialog(im.actor.core.js.entity.JsDialog) Message(im.actor.core.entity.Message) Dialog(im.actor.core.entity.Dialog) WebRTCMediaStream(im.actor.runtime.webrtc.WebRTCMediaStream) JsGroup(im.actor.core.js.entity.JsGroup) CallState(im.actor.core.viewmodel.CallState) ValueChangedListener(im.actor.runtime.mvvm.ValueChangedListener) JsDisplayListBind(im.actor.runtime.js.mvvm.JsDisplayListBind) JsOnlineGroup(im.actor.core.js.entity.JsOnlineGroup) JsEventBusCallback(im.actor.core.js.entity.JsEventBusCallback) UserPresence(im.actor.core.viewmodel.UserPresence) HashMap(java.util.HashMap) StickerContent(im.actor.core.entity.content.StickerContent) GroupVM(im.actor.core.viewmodel.GroupVM) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) JsSearchEntity(im.actor.core.js.entity.JsSearchEntity) AbsModule(im.actor.core.modules.AbsModule) CallVM(im.actor.core.viewmodel.CallVM) Modules(im.actor.core.modules.Modules) GlobalStateVM(im.actor.core.viewmodel.GlobalStateVM) JsTyping(im.actor.core.js.entity.JsTyping) Contact(im.actor.core.entity.Contact) SearchEntity(im.actor.core.entity.SearchEntity) JsMessenger(im.actor.core.js.JsMessenger) PeerType(im.actor.core.entity.PeerType) JsOnlineUser(im.actor.core.js.entity.JsOnlineUser) JsCall(im.actor.core.js.entity.JsCall) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsCounter(im.actor.core.js.entity.JsCounter) JsSticker(im.actor.core.js.entity.JsSticker) JsArray(com.google.gwt.core.client.JsArray) FileRemoteSource(im.actor.core.entity.content.FileRemoteSource) UserVM(im.actor.core.viewmodel.UserVM) DialogGroup(im.actor.core.viewmodel.DialogGroup) ModelChangedListener(im.actor.runtime.mvvm.ModelChangedListener) JsBlockedUser(im.actor.core.js.entity.JsBlockedUser) JsDisplayList(im.actor.runtime.js.mvvm.JsDisplayList) Value(im.actor.runtime.mvvm.Value) GroupTypingVM(im.actor.core.viewmodel.GroupTypingVM) JsTyping(im.actor.core.js.entity.JsTyping) ArrayList(java.util.ArrayList)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JsArray (com.google.gwt.core.client.JsArray)1 Avatar (im.actor.core.entity.Avatar)1 Contact (im.actor.core.entity.Contact)1 Dialog (im.actor.core.entity.Dialog)1 Message (im.actor.core.entity.Message)1 Peer (im.actor.core.entity.Peer)1 PeerType (im.actor.core.entity.PeerType)1 SearchEntity (im.actor.core.entity.SearchEntity)1 Sticker (im.actor.core.entity.Sticker)1 StickerPack (im.actor.core.entity.StickerPack)1 DocumentContent (im.actor.core.entity.content.DocumentContent)1 FileRemoteSource (im.actor.core.entity.content.FileRemoteSource)1 StickerContent (im.actor.core.entity.content.StickerContent)1 JsMessenger (im.actor.core.js.JsMessenger)1 JsBlockedUser (im.actor.core.js.entity.JsBlockedUser)1 JsCall (im.actor.core.js.entity.JsCall)1 JsContact (im.actor.core.js.entity.JsContact)1 JsCounter (im.actor.core.js.entity.JsCounter)1 JsDialog (im.actor.core.js.entity.JsDialog)1