test(settings) : try to fix flakiness
This commit is contained in:
parent
865f877bb7
commit
34b81435fc
4 changed files with 119 additions and 122 deletions
|
|
@ -23,6 +23,7 @@ import io.element.android.features.logout.api.LogoutUseCase
|
|||
import io.element.android.features.preferences.impl.tasks.ClearCacheUseCase
|
||||
import io.element.android.features.preferences.impl.tasks.ComputeCacheSizeUseCase
|
||||
import io.element.android.features.rageshake.api.preferences.RageshakePreferencesState
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.architecture.runCatchingUpdatingState
|
||||
|
|
@ -63,7 +64,7 @@ class DeveloperSettingsPresenter @Inject constructor(
|
|||
mutableStateOf<AsyncData<String>>(AsyncData.Uninitialized)
|
||||
}
|
||||
val clearCacheAction = remember {
|
||||
mutableStateOf<AsyncData<Unit>>(AsyncData.Uninitialized)
|
||||
mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized)
|
||||
}
|
||||
val customElementCallBaseUrl by appPreferencesStore
|
||||
.getCustomElementCallBaseUrlFlow()
|
||||
|
|
@ -94,7 +95,7 @@ class DeveloperSettingsPresenter @Inject constructor(
|
|||
val featureUiModels = createUiModels(features, enabledFeatures)
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
// Compute cache size each time the clear cache action value is changed
|
||||
LaunchedEffect(clearCacheAction.value) {
|
||||
LaunchedEffect(clearCacheAction.value.isSuccess()) {
|
||||
computeCacheSize(cacheSize)
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +181,7 @@ class DeveloperSettingsPresenter @Inject constructor(
|
|||
}.runCatchingUpdatingState(cacheSize)
|
||||
}
|
||||
|
||||
private fun CoroutineScope.clearCache(clearCacheAction: MutableState<AsyncData<Unit>>) = launch {
|
||||
private fun CoroutineScope.clearCache(clearCacheAction: MutableState<AsyncAction<Unit>>) = launch {
|
||||
suspend {
|
||||
clearCacheUseCase()
|
||||
}.runCatchingUpdatingState(clearCacheAction)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
package io.element.android.features.preferences.impl.developer
|
||||
|
||||
import io.element.android.features.rageshake.api.preferences.RageshakePreferencesState
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.featureflag.ui.model.FeatureUiModel
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
|
@ -16,7 +17,7 @@ data class DeveloperSettingsState(
|
|||
val features: ImmutableList<FeatureUiModel>,
|
||||
val cacheSize: AsyncData<String>,
|
||||
val rageshakeState: RageshakePreferencesState,
|
||||
val clearCacheAction: AsyncData<Unit>,
|
||||
val clearCacheAction: AsyncAction<Unit>,
|
||||
val customElementCallBaseUrlState: CustomElementCallBaseUrlState,
|
||||
val isSimpleSlidingSyncEnabled: Boolean,
|
||||
val hideImagesAndVideos: Boolean,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ package io.element.android.features.preferences.impl.developer
|
|||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.features.rageshake.api.preferences.aRageshakePreferencesState
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.featureflag.ui.model.aFeatureUiModelList
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ open class DeveloperSettingsStateProvider : PreviewParameterProvider<DeveloperSe
|
|||
get() = sequenceOf(
|
||||
aDeveloperSettingsState(),
|
||||
aDeveloperSettingsState(
|
||||
clearCacheAction = AsyncData.Loading()
|
||||
clearCacheAction = AsyncAction.Loading
|
||||
),
|
||||
aDeveloperSettingsState(
|
||||
customElementCallBaseUrlState = aCustomElementCallBaseUrlState(
|
||||
|
|
@ -28,7 +29,7 @@ open class DeveloperSettingsStateProvider : PreviewParameterProvider<DeveloperSe
|
|||
}
|
||||
|
||||
fun aDeveloperSettingsState(
|
||||
clearCacheAction: AsyncData<Unit> = AsyncData.Uninitialized,
|
||||
clearCacheAction: AsyncAction<Unit> = AsyncAction.Uninitialized,
|
||||
customElementCallBaseUrlState: CustomElementCallBaseUrlState = aCustomElementCallBaseUrlState(),
|
||||
isSimplifiedSlidingSyncEnabled: Boolean = false,
|
||||
hideImagesAndVideos: Boolean = false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue