Unverified Commit d0e0db18 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #1593 from RocketChat/fix/fix-manual-reconnection

[IMPROVEMENT] immediately try to reconnect when coming from the Background.
parents 691b8109 2759d3fb
......@@ -22,6 +22,9 @@ class AppLifecycleObserver @Inject constructor(
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onEnterForeground() {
changeTemporaryStatus(UserStatus.Online())
serverInteractor.get()?.let { currentServer ->
factory.create(currentServer).resetReconnectionTimer()
}
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
......
......@@ -193,6 +193,14 @@ class ConnectionManager(
client.setTemporaryStatus(userStatus)
}
fun resetReconnectionTimer() {
// if we are waiting to reconnect, immediately try to reconnect
// and reset the reconnection counter
if (client.state is State.Waiting) {
client.connect(resetCounter = true)
}
}
private fun resubscribeRooms() {
roomMessagesChannels.toList().map { (roomId, channel) ->
client.subscribeRoomMessages(roomId) { _, id ->
......
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