mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Avoid runBlocking. Start with a nullable boolean.
This commit is contained in:
committed by
Benoit Marty
parent
5013ff061e
commit
d09d95b269
+6
-6
@@ -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.BackupUploadState
|
||||||
import io.element.android.libraries.matrix.api.encryption.EncryptionService
|
import io.element.android.libraries.matrix.api.encryption.EncryptionService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.flow.emptyFlow
|
||||||
import kotlinx.coroutines.flow.flowOf
|
import kotlinx.coroutines.flow.flowOf
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LogoutPresenter @Inject constructor(
|
class LogoutPresenter @Inject constructor(
|
||||||
@@ -53,13 +53,13 @@ class LogoutPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
||||||
.collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) })
|
.collectAsState(initial = null)
|
||||||
|
|
||||||
val backupUploadState: BackupUploadState by remember(secureStorageFlag) {
|
val backupUploadState: BackupUploadState by remember(secureStorageFlag) {
|
||||||
if (secureStorageFlag) {
|
when (secureStorageFlag) {
|
||||||
encryptionService.waitForBackupUploadSteadyState()
|
true -> encryptionService.waitForBackupUploadSteadyState()
|
||||||
} else {
|
false -> flowOf(BackupUploadState.Done)
|
||||||
flowOf(BackupUploadState.Done)
|
else -> emptyFlow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.collectAsState(initial = BackupUploadState.Unknown)
|
.collectAsState(initial = BackupUploadState.Unknown)
|
||||||
|
|||||||
+2
-3
@@ -39,7 +39,6 @@ import io.element.android.libraries.matrix.api.verification.SessionVerificationS
|
|||||||
import io.element.android.services.analytics.api.AnalyticsService
|
import io.element.android.services.analytics.api.AnalyticsService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class PreferencesRootPresenter @Inject constructor(
|
class PreferencesRootPresenter @Inject constructor(
|
||||||
@@ -80,7 +79,7 @@ class PreferencesRootPresenter @Inject constructor(
|
|||||||
val showSecureBackupIndicator by indicatorService.showSettingChatBackupIndicator()
|
val showSecureBackupIndicator by indicatorService.showSettingChatBackupIndicator()
|
||||||
|
|
||||||
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
||||||
.collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) })
|
.collectAsState(initial = null)
|
||||||
|
|
||||||
val accountManagementUrl: MutableState<String?> = remember {
|
val accountManagementUrl: MutableState<String?> = remember {
|
||||||
mutableStateOf(null)
|
mutableStateOf(null)
|
||||||
@@ -98,7 +97,7 @@ class PreferencesRootPresenter @Inject constructor(
|
|||||||
myUser = matrixUser.value,
|
myUser = matrixUser.value,
|
||||||
version = versionFormatter.get(),
|
version = versionFormatter.get(),
|
||||||
showCompleteVerification = showCompleteVerification,
|
showCompleteVerification = showCompleteVerification,
|
||||||
showSecureBackup = !showCompleteVerification && secureStorageFlag,
|
showSecureBackup = !showCompleteVerification && secureStorageFlag == true,
|
||||||
showSecureBackupBadge = showSecureBackupIndicator,
|
showSecureBackupBadge = showSecureBackupIndicator,
|
||||||
accountManagementUrl = accountManagementUrl.value,
|
accountManagementUrl = accountManagementUrl.value,
|
||||||
devicesManagementUrl = devicesManagementUrl.value,
|
devicesManagementUrl = devicesManagementUrl.value,
|
||||||
|
|||||||
+2
-3
@@ -46,7 +46,6 @@ import io.element.android.libraries.matrix.api.user.getCurrentUser
|
|||||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
private const val EXTENDED_RANGE_SIZE = 40
|
private const val EXTENDED_RANGE_SIZE = 40
|
||||||
@@ -89,11 +88,11 @@ class RoomListPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
|
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
|
||||||
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
||||||
.collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) })
|
.collectAsState(initial = null)
|
||||||
var recoveryKeyPromptDismissed by rememberSaveable { mutableStateOf(false) }
|
var recoveryKeyPromptDismissed by rememberSaveable { mutableStateOf(false) }
|
||||||
val displayRecoveryKeyPrompt by remember {
|
val displayRecoveryKeyPrompt by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
secureStorageFlag &&
|
secureStorageFlag == true &&
|
||||||
recoveryState == RecoveryState.INCOMPLETE &&
|
recoveryState == RecoveryState.INCOMPLETE &&
|
||||||
!recoveryKeyPromptDismissed
|
!recoveryKeyPromptDismissed
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -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.EncryptionService
|
||||||
import io.element.android.libraries.matrix.api.encryption.RecoveryState
|
import io.element.android.libraries.matrix.api.encryption.RecoveryState
|
||||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ContributesBinding(SessionScope::class)
|
@ContributesBinding(SessionScope::class)
|
||||||
@@ -56,7 +55,7 @@ class DefaultIndicatorService @Inject constructor(
|
|||||||
@Composable
|
@Composable
|
||||||
override fun showSettingChatBackupIndicator(): State<Boolean> {
|
override fun showSettingChatBackupIndicator(): State<Boolean> {
|
||||||
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
||||||
.collectAsState(initial = runBlocking { featureFlagService.isFeatureEnabled(FeatureFlags.SecureStorage) })
|
.collectAsState(initial = null)
|
||||||
val backupState by encryptionService.backupStateStateFlow.collectAsState()
|
val backupState by encryptionService.backupStateStateFlow.collectAsState()
|
||||||
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
|
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ class DefaultIndicatorService @Inject constructor(
|
|||||||
RecoveryState.DISABLED,
|
RecoveryState.DISABLED,
|
||||||
RecoveryState.INCOMPLETE,
|
RecoveryState.INCOMPLETE,
|
||||||
)
|
)
|
||||||
secureStorageFlag && (showForBackup || showForRecovery)
|
secureStorageFlag == true && (showForBackup || showForRecovery)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user