Commit 2b009fff authored by Leonardo Aramaki's avatar Leonardo Aramaki

Schedule KeepAliveJob when online

parent ad4bab2f
......@@ -16,6 +16,7 @@ import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.helper.Logger;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.service.ConnectivityManagerApi;
import chat.rocket.android.service.KeepAliveJob;
import chat.rocket.android.service.ServerConnectivity;
import chat.rocket.android.shared.BasePresenter;
import chat.rocket.android_ddp.DDPClient;
......@@ -211,8 +212,8 @@ public class MainPresenter extends BasePresenter<MainContract.View>
view.showConnecting();
return;
}
// view.showConnectionOk();
// TODO: Should we remove below and above calls to view?
// view.showConnectionOk();
},
Logger::report
);
......@@ -227,10 +228,13 @@ public class MainPresenter extends BasePresenter<MainContract.View>
.subscribe(
connectivity -> {
if (connectivity.state == ServerConnectivity.STATE_CONNECTED) {
KeepAliveJob.Companion.cancel();
//TODO: notify almost connected or something like that.
// view.showConnectionOk();
} else if (connectivity.state == ServerConnectivity.STATE_DISCONNECTED) {
KeepAliveJob.Companion.cancel();
if (connectivity.code == DDPClient.REASON_NETWORK_ERROR) {
KeepAliveJob.Companion.schedule();
view.showConnectionError();
}
} else if (connectivity.state == ServerConnectivity.STATE_SESSION_ESTABLISHED) {
......@@ -240,7 +244,7 @@ public class MainPresenter extends BasePresenter<MainContract.View>
view.showConnecting();
}
},
Logger::report
RCLog::e
);
addSubscription(disposable);
......
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