Commit bb01f6a6 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #400 from filipedelimabrito/iss321

Spotlight changes.
parents b9d36651 5c8721d7
...@@ -365,9 +365,10 @@ public class MethodCallHelper { ...@@ -365,9 +365,10 @@ public class MethodCallHelper {
.onSuccessTask(task -> Task.forResult(null)); .onSuccessTask(task -> Task.forResult(null));
} }
public Task<Void> createDirectMessage(final String username) { public Task<String> createDirectMessage(final String username) {
return call("createDirectMessage", TIMEOUT_MS, () -> new JSONArray().put(username)) return call("createDirectMessage", TIMEOUT_MS, () -> new JSONArray().put(username))
.onSuccessTask(task -> Task.forResult(null)); .onSuccessTask(CONVERT_TO_JSON_OBJECT)
.onSuccessTask(task -> Task.forResult(task.getResult().getString("rid")));
} }
/** /**
......
...@@ -98,7 +98,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View ...@@ -98,7 +98,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
methodCallHelper.createDirectMessage(username) methodCallHelper.createDirectMessage(username)
.continueWithTask(task -> { .continueWithTask(task -> {
if (task.isCompleted()) { if (task.isCompleted()) {
rocketChatCache.setSelectedRoomId(spotlight.getId() + userId); rocketChatCache.setSelectedRoomId(task.getResult());
} }
return null; return null;
}); });
......
...@@ -105,6 +105,7 @@ public class AddDirectMessageDialogFragment extends AbstractAddRoomDialogFragmen ...@@ -105,6 +105,7 @@ public class AddDirectMessageDialogFragment extends AbstractAddRoomDialogFragmen
protected Task<Void> getMethodCallForSubmitAction() { protected Task<Void> getMethodCallForSubmitAction() {
String username = String username =
((TextView) getDialog().findViewById(R.id.editor_username)).getText().toString(); ((TextView) getDialog().findViewById(R.id.editor_username)).getText().toString();
return methodCall.createDirectMessage(username); return methodCall.createDirectMessage(username)
.onSuccess(task -> 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