diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt index 68bc9b76a0..ff76bde776 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt @@ -34,9 +34,9 @@ import io.element.android.libraries.matrix.api.MatrixClient import io.element.android.libraries.matrix.api.encryption.BackupUploadState import io.element.android.libraries.matrix.api.encryption.EncryptionService import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import javax.inject.Inject class LogoutPresenter @Inject constructor( @@ -53,13 +53,13 @@ class LogoutPresenter @Inject constructor( } val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage) - .collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) }) + .collectAsState(initial = null) val backupUploadState: BackupUploadState by remember(secureStorageFlag) { - if (secureStorageFlag) { - encryptionService.waitForBackupUploadSteadyState() - } else { - flowOf(BackupUploadState.Done) + when (secureStorageFlag) { + true -> encryptionService.waitForBackupUploadSteadyState() + false -> flowOf(BackupUploadState.Done) + else -> emptyFlow() } } .collectAsState(initial = BackupUploadState.Unknown) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt index 5e40d7e54d..3295e3a59a 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt @@ -39,7 +39,6 @@ import io.element.android.libraries.matrix.api.verification.SessionVerificationS import io.element.android.services.analytics.api.AnalyticsService import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import javax.inject.Inject class PreferencesRootPresenter @Inject constructor( @@ -80,7 +79,7 @@ class PreferencesRootPresenter @Inject constructor( val showSecureBackupIndicator by indicatorService.showSettingChatBackupIndicator() val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage) - .collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) }) + .collectAsState(initial = null) val accountManagementUrl: MutableState = remember { mutableStateOf(null) @@ -98,7 +97,7 @@ class PreferencesRootPresenter @Inject constructor( myUser = matrixUser.value, version = versionFormatter.get(), showCompleteVerification = showCompleteVerification, - showSecureBackup = !showCompleteVerification && secureStorageFlag, + showSecureBackup = !showCompleteVerification && secureStorageFlag == true, showSecureBackupBadge = showSecureBackupIndicator, accountManagementUrl = accountManagementUrl.value, devicesManagementUrl = devicesManagementUrl.value, diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt index ee2b706871..a587af0692 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt @@ -46,7 +46,6 @@ import io.element.android.libraries.matrix.api.user.getCurrentUser import io.element.android.libraries.matrix.api.verification.SessionVerificationService import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import javax.inject.Inject private const val EXTENDED_RANGE_SIZE = 40 @@ -89,11 +88,11 @@ class RoomListPresenter @Inject constructor( } val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState() val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage) - .collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) }) + .collectAsState(initial = null) var recoveryKeyPromptDismissed by rememberSaveable { mutableStateOf(false) } val displayRecoveryKeyPrompt by remember { derivedStateOf { - secureStorageFlag && + secureStorageFlag == true && recoveryState == RecoveryState.INCOMPLETE && !recoveryKeyPromptDismissed } diff --git a/libraries/indicator/impl/src/main/kotlin/io/element/android/libraries/indicator/impl/DefaultIndicatorService.kt b/libraries/indicator/impl/src/main/kotlin/io/element/android/libraries/indicator/impl/DefaultIndicatorService.kt index 0ff5ab058c..a47da27a38 100644 --- a/libraries/indicator/impl/src/main/kotlin/io/element/android/libraries/indicator/impl/DefaultIndicatorService.kt +++ b/libraries/indicator/impl/src/main/kotlin/io/element/android/libraries/indicator/impl/DefaultIndicatorService.kt @@ -31,7 +31,6 @@ import io.element.android.libraries.matrix.api.encryption.BackupState import io.element.android.libraries.matrix.api.encryption.EncryptionService import io.element.android.libraries.matrix.api.encryption.RecoveryState import io.element.android.libraries.matrix.api.verification.SessionVerificationService -import kotlinx.coroutines.runBlocking import javax.inject.Inject @ContributesBinding(SessionScope::class) @@ -56,7 +55,7 @@ class DefaultIndicatorService @Inject constructor( @Composable override fun showSettingChatBackupIndicator(): State { val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage) - .collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) }) + .collectAsState(initial = null) val backupState by encryptionService.backupStateStateFlow.collectAsState() val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState() @@ -69,7 +68,7 @@ class DefaultIndicatorService @Inject constructor( RecoveryState.DISABLED, RecoveryState.INCOMPLETE, ) - secureStorageFlag && (showForBackup || showForRecovery) + secureStorageFlag == true && (showForBackup || showForRecovery) } } }