Commit 4f259cc3 authored by Tiago Cunha's avatar Tiago Cunha Committed by GitHub

Merge pull request #243 from RocketChat/fix/room-npe

Crashes
parents b704af6f 54b7af44
......@@ -57,11 +57,19 @@ public class DefaultServerPolicyApi implements ServerPolicyApi {
return new okhttp3.Callback() {
@Override
public void onFailure(Call call, IOException ioException) {
if (emitter.isCancelled()) {
return;
}
emitter.onError(ioException);
}
@Override
public void onResponse(Call call, okhttp3.Response response) throws IOException {
if (emitter.isCancelled()) {
return;
}
if (!response.isSuccessful()) {
emitter.onNext(new Response<>(false, protocol, null));
emitter.onComplete();
......
......@@ -53,9 +53,7 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
view.showInvalidServerError();
}
},
throwable -> {
view.showConnectionError();
});
throwable -> view.showConnectionError());
addSubscription(subscription);
}
......
......@@ -36,8 +36,6 @@ public interface RoomContract {
void loadMoreMessages();
void onViewSetup();
void onMessageSelected(@Nullable Message message);
void sendMessage(String messageText);
......
......@@ -202,8 +202,6 @@ public class RoomFragment extends AbstractChatRoomFragment
setupSideMenu();
setupMessageComposer();
setupMessageActions();
presenter.onViewSetup();
}
private void setupMessageActions() {
......
......@@ -59,6 +59,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
getRoomHistoryStateInfo();
getMessages();
getUserPreferences();
getAbsoluteUrl();
}
@Override
......@@ -76,16 +77,6 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
addSubscription(subscription);
}
@Override
public void onViewSetup() {
final Disposable subscription = absoluteUrlHelper.getRocketChatAbsoluteUrl()
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(it -> view.setupWith(it.orNull()));
addSubscription(subscription);
}
@Override
public void loadMoreMessages() {
......@@ -248,6 +239,15 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
addSubscription(subscription);
}
private void getAbsoluteUrl() {
final Disposable subscription = absoluteUrlHelper.getRocketChatAbsoluteUrl()
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(it -> view.setupWith(it.orNull()));
addSubscription(subscription);
}
private Single<Pair<Room, User>> getRoomUserPair() {
return Single.zip(
getSingleRoom(),
......
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