Skip to content

Commit

Permalink
Check server session state in registered check to avoid transferred s…
Browse files Browse the repository at this point in the history
…ervers
  • Loading branch information
jpelgrom committed Feb 8, 2025
1 parent cb99f4c commit 7d38cf7
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 7d38cf7

Please sign in to comment.