Session falsely displayed as 'verified' with no internet connection (#2884)

* Session falsely displayed as 'verified' with no internet connection
	- Remove the need to wait for `isReady` for `SessionVerificationService.canVerifySessionFlow` to fix this.
	- Rename `SessionVerificationService.canVerifySessionFlow` to `needsSessionVerification`.
	- Make `isReady` private.
This commit is contained in:
Jorge Martin Espinosa 2024-05-21 13:41:18 +02:00 committed by GitHub
parent bce1a30249
commit 0e05a0e4ed
9 changed files with 21 additions and 31 deletions

View file

@ -74,7 +74,7 @@ class PreferencesRootPresenter @Inject constructor(
}
// We should display the 'complete verification' option if the current session can be verified
val canVerifyUserSession by sessionVerificationService.canVerifySessionFlow.collectAsState(false)
val canVerifyUserSession by sessionVerificationService.needsSessionVerification.collectAsState(false)
val showSecureBackupIndicator by indicatorService.showSettingChatBackupIndicator()

View file

@ -140,7 +140,7 @@ class RoomListPresenterTests {
}.test {
val initialState = awaitItem()
assertThat(initialState.showAvatarIndicator).isTrue()
sessionVerificationService.givenCanVerifySession(false)
sessionVerificationService.givenNeedsSessionVerification(false)
encryptionService.emitBackupState(BackupState.ENABLED)
val finalState = awaitItem()
assertThat(finalState.showAvatarIndicator).isFalse()
@ -282,7 +282,7 @@ class RoomListPresenterTests {
roomListService = roomListService,
encryptionService = encryptionService,
sessionVerificationService = FakeSessionVerificationService().apply {
givenCanVerifySession(false)
givenNeedsSessionVerification(false)
},
syncService = FakeSyncService(initialState = SyncState.Running)
)

View file

@ -25,7 +25,6 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import com.freeletics.flowredux.compose.rememberStateAndDispatch
import io.element.android.features.preferences.api.store.SessionPreferencesStore
import io.element.android.libraries.architecture.AsyncData
@ -61,7 +60,7 @@ class VerifySelfSessionPresenter @Inject constructor(
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
val stateAndDispatch = stateMachine.rememberStateAndDispatch()
val skipVerification by sessionPreferencesStore.isSessionVerificationSkipped().collectAsState(initial = false)
val needsVerification by sessionVerificationService.canVerifySessionFlow.collectAsState(initial = true)
val needsVerification by sessionVerificationService.needsSessionVerification.collectAsState(initial = true)
val verificationFlowStep by remember {
derivedStateOf {
when {

View file

@ -296,8 +296,7 @@ class VerifySelfSessionPresenterTests {
@Test
fun `present - When verification is not needed, the flow is completed`() = runTest {
val service = FakeSessionVerificationService().apply {
givenCanVerifySession(false)
givenIsReady(true)
givenNeedsSessionVerification(false)
givenVerifiedStatus(SessionVerifiedStatus.Verified)
givenVerificationFlowState(VerificationFlowState.Finished)
}