Session database: use the new count API.

This commit is contained in:
Benoit Marty
2025-11-04 15:30:29 +01:00
parent 9070420860
commit 0367ae610c
4 changed files with 6 additions and 4 deletions

View File

@@ -349,7 +349,7 @@ class RootFlowNode(
} else {
// wait for the current session to be restored
val loggedInFlowNode = attachSession(latestSessionId)
if (sessionStore.getAllSessions().size > 1) {
if (sessionStore.numberOfSessions() > 1) {
// Several accounts, let the user choose which one to use
backstack.push(
NavTarget.AccountSelect(
@@ -379,7 +379,7 @@ class RootFlowNode(
is PermalinkData.FallbackLink -> Unit
is PermalinkData.RoomEmailInviteLink -> Unit
else -> {
if (sessionStore.getAllSessions().size > 1) {
if (sessionStore.numberOfSessions() > 1) {
// Several accounts, let the user choose which one to use
backstack.push(
NavTarget.AccountSelect(

View File

@@ -90,7 +90,7 @@ class OnBoardingPresenter(
}
val isAddingAccount by produceState(initialValue = false) {
// We are adding an account if there is at least one session already stored
value = sessionStore.getAllSessions().isNotEmpty()
value = sessionStore.numberOfSessions() > 0
}
val loginMode by loginHelper.collectLoginMode()

View File

@@ -165,7 +165,7 @@ class DefaultBugReporter(
}
}
val sessionData = sessionStore.getLatestSession()
val numberOfAccounts = sessionStore.getAllSessions().size
val numberOfAccounts = sessionStore.numberOfSessions()
val deviceId = sessionData?.deviceId ?: "undefined"
val userId = sessionData?.userId?.let { UserId(it) }
// build the multi part request

View File

@@ -58,9 +58,11 @@ class SignedOutPresenterTest {
val initialState = awaitItem()
assertThat(initialState.signedOutSession).isEqualTo(aSessionData)
assertThat(sessionStore.getAllSessions()).isNotEmpty()
assertThat(sessionStore.numberOfSessions()).isEqualTo(1)
initialState.eventSink(SignedOutEvents.SignInAgain)
assertThat(awaitItem().signedOutSession).isNull()
assertThat(sessionStore.getAllSessions()).isEmpty()
assertThat(sessionStore.numberOfSessions()).isEqualTo(0)
}
}
}