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; ...@@ -12,6 +12,7 @@ import chat.rocket.android.fragment.chatroom.HomeFragment;
import chat.rocket.android.fragment.chatroom.RoomFragment; import chat.rocket.android.fragment.chatroom.RoomFragment;
import chat.rocket.android.fragment.sidebar.SidebarMainFragment; import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.model.ddp.User;
import chat.rocket.android.model.internal.Session; import chat.rocket.android.model.internal.Session;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.realm_helper.RealmObjectObserver; import chat.rocket.android.realm_helper.RealmObjectObserver;
...@@ -55,14 +56,14 @@ public class MainActivity extends AbstractAuthedActivity { ...@@ -55,14 +56,14 @@ public class MainActivity extends AbstractAuthedActivity {
private void setUserOnlineIfServerAvailable() { private void setUserOnlineIfServerAvailable() {
if (serverConfigId != null) { if (serverConfigId != null) {
new MethodCallHelper(this, serverConfigId).setUserOnline() new MethodCallHelper(this, serverConfigId).setUserPresence(User.STATUS_ONLINE)
.continueWith(new LogcatIfError()); .continueWith(new LogcatIfError());
} }
} }
private void setUserAwayIfServerAvailable() { private void setUserAwayIfServerAvailable() {
if (serverConfigId != null) { if (serverConfigId != null) {
new MethodCallHelper(this, serverConfigId).setUserAway() new MethodCallHelper(this, serverConfigId).setUserPresence(User.STATUS_AWAY)
.continueWith(new LogcatIfError()); .continueWith(new LogcatIfError());
} }
} }
......
...@@ -278,13 +278,8 @@ public class MethodCallHelper { ...@@ -278,13 +278,8 @@ public class MethodCallHelper {
.onSuccessTask(task -> Task.forResult(null)); .onSuccessTask(task -> Task.forResult(null));
} }
public Task<Void> setUserAway() { public Task<Void> setUserPresence(final String status) {
return call("UserPresence:away", TIMEOUT_MS, JSONArray::new) return call("UserPresence:" + status, TIMEOUT_MS)
.onSuccessTask(task -> Task.forResult(null));
}
public Task<Void> setUserOnline() {
return call("UserPresence:online", TIMEOUT_MS, JSONArray::new)
.onSuccessTask(task -> Task.forResult(null)); .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