Search in sources :

Example 6 with UsedByApp

use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.

the class JsFacade method joinGroupViaLink.

@UsedByApp
public JsPromise joinGroupViaLink(final String url) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            //noinspection ConstantConditions
            messenger.joinGroupViaToken(url).start(new CommandCallback<Integer>() {

                @Override
                public void onResult(Integer res) {
                    Log.d(TAG, "joinGroupViaLink:result");
                    resolve(JsPeer.create(Peer.group(res)));
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "joinGroupViaLink:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) CommandCallback(im.actor.core.viewmodel.CommandCallback) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 7 with UsedByApp

use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.

the class JsFacade method findUsers.

@UsedByApp
public JsPromise findUsers(final String query) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.findUsers(query).start(new CommandCallback<UserVM[]>() {

                @Override
                public void onResult(UserVM[] users) {
                    Log.d(TAG, "findUsers:result");
                    JsArray<JsUser> jsUsers = JsArray.createArray().cast();
                    for (UserVM user : users) {
                        jsUsers.push(messenger.getJsUser(user.getId()).get());
                    }
                    resolve(jsUsers);
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "findUsers:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) UserVM(im.actor.core.viewmodel.UserVM) CommandCallback(im.actor.core.viewmodel.CommandCallback) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 8 with UsedByApp

use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.

the class JsFacade method handleLinkClick.

@UsedByApp
public void handleLinkClick(Event event) {
    Element target = Element.as(event.getEventTarget());
    String href = target.getAttribute("href");
    if (href.startsWith("send:")) {
        String msg = href.substring("send:".length());
        msg = URL.decode(msg);
        if (lastVisiblePeer != null) {
            messenger.sendMessage(lastVisiblePeer, msg);
            event.preventDefault();
        }
    } else {
        if (JsElectronApp.isElectron()) {
            JsElectronApp.openUrlExternal(href);
            event.preventDefault();
        }
    }
}
Also used : Element(com.google.gwt.dom.client.Element) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 9 with UsedByApp

use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.

the class JsFacade method archiveChat.

@UsedByApp
public JsPromise archiveChat(final JsPeer peer) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.archiveChat(peer.convert()).start(new CommandCallback<Void>() {

                @Override
                public void onResult(Void res) {
                    Log.d(TAG, "archiveChat:result");
                    resolve();
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "archiveChat:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) CommandCallback(im.actor.core.viewmodel.CommandCallback) Void(im.actor.runtime.actors.messages.Void) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 10 with UsedByApp

use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.

the class JsFacade method terminateSession.

@UsedByApp
public JsPromise terminateSession(final int id) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.terminateSession(id).start(new CommandCallback<Void>() {

                @Override
                public void onResult(Void res) {
                    resolve();
                }

                @Override
                public void onError(Exception e) {
                    Log.e(TAG, e);
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) CommandCallback(im.actor.core.viewmodel.CommandCallback) Void(im.actor.runtime.actors.messages.Void) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Aggregations

UsedByApp (im.actor.core.js.annotations.UsedByApp)32 RpcException (im.actor.core.network.RpcException)29 JsPromiseExecutor (im.actor.runtime.js.utils.JsPromiseExecutor)29 CommandCallback (im.actor.core.viewmodel.CommandCallback)28 Void (im.actor.runtime.actors.messages.Void)9 ArrayList (java.util.ArrayList)5 List (java.util.List)5 MessageSearchEntity (im.actor.core.entity.MessageSearchEntity)4 Element (com.google.gwt.dom.client.Element)1 ApiAuthSession (im.actor.core.api.ApiAuthSession)1 ApiDialog (im.actor.core.api.ApiDialog)1 ResponseLoadArchived (im.actor.core.api.rpc.ResponseLoadArchived)1 MentionFilterResult (im.actor.core.entity.MentionFilterResult)1 JsCallsProvider (im.actor.core.js.providers.JsCallsProvider)1 JsNotificationsProvider (im.actor.core.js.providers.JsNotificationsProvider)1 JsPhoneBookProvider (im.actor.core.js.providers.JsPhoneBookProvider)1 RpcCallback (im.actor.core.network.RpcCallback)1 UserVM (im.actor.core.viewmodel.UserVM)1 JsLogProvider (im.actor.runtime.js.JsLogProvider)1 Date (java.util.Date)1