Skip to content

Commit

Permalink
Check session state in registered check to avoid using transferred se…
Browse files Browse the repository at this point in the history
…rvers more (#5037)

Check server session state in registered check to avoid transferred servers
  • Loading branch information
jpelgrom authored Feb 8, 2025
1 parent df01039 commit 4a3ece7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.homeassistant.companion.android.common.data.servers
import io.homeassistant.companion.android.common.data.LocalStorage
import io.homeassistant.companion.android.common.data.authentication.AuthenticationRepository
import io.homeassistant.companion.android.common.data.authentication.AuthenticationRepositoryFactory
import io.homeassistant.companion.android.common.data.authentication.SessionState
import io.homeassistant.companion.android.common.data.integration.IntegrationRepository
import io.homeassistant.companion.android.common.data.integration.IntegrationRepositoryFactory
import io.homeassistant.companion.android.common.data.prefs.PrefsRepository
Expand Down Expand Up @@ -85,7 +86,11 @@ class ServerManagerImpl @Inject constructor(
}

override fun isRegistered(): Boolean =
mutableServers.values.any { it.type == ServerType.DEFAULT && it.connection.isRegistered() }
mutableServers.values.any {
it.type == ServerType.DEFAULT &&
it.connection.isRegistered() &&
authenticationRepository(it.id).getSessionState() == SessionState.CONNECTED
}

override suspend fun addServer(server: Server): Int {
val newServer = server.copy(
Expand Down

0 comments on commit 4a3ece7

Please sign in to comment.