Avoid runBlocking. Start with a nullable boolean.
This commit is contained in:
parent
5013ff061e
commit
d09d95b269
4 changed files with 12 additions and 15 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<String?> = 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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Boolean> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue