Commit b62277c9 authored by Yusuke Iwaki's avatar Yusuke Iwaki

refactor method serUserPresence

parent f4cbe1ba
......@@ -12,6 +12,7 @@ import chat.rocket.android.fragment.chatroom.HomeFragment;
import chat.rocket.android.fragment.chatroom.RoomFragment;
import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.model.ddp.User;
import chat.rocket.android.model.internal.Session;
import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.realm_helper.RealmObjectObserver;
......@@ -55,14 +56,14 @@ public class MainActivity extends AbstractAuthedActivity {
private void setUserOnlineIfServerAvailable() {
if (serverConfigId != null) {
new MethodCallHelper(this, serverConfigId).setUserOnline()
new MethodCallHelper(this, serverConfigId).setUserPresence(User.STATUS_ONLINE)
.continueWith(new LogcatIfError());
}
}
private void setUserAwayIfServerAvailable() {
if (serverConfigId != null) {
new MethodCallHelper(this, serverConfigId).setUserAway()
new MethodCallHelper(this, serverConfigId).setUserPresence(User.STATUS_AWAY)
.continueWith(new LogcatIfError());
}
}
......
......@@ -278,13 +278,8 @@ public class MethodCallHelper {
.onSuccessTask(task -> Task.forResult(null));
}
public Task<Void> setUserAway() {
return call("UserPresence:away", TIMEOUT_MS, JSONArray::new)
.onSuccessTask(task -> Task.forResult(null));
}
public Task<Void> setUserOnline() {
return call("UserPresence:online", TIMEOUT_MS, JSONArray::new)
public Task<Void> setUserPresence(final String status) {
return call("UserPresence:" + status, TIMEOUT_MS)
.onSuccessTask(task -> Task.forResult(null));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment