diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt index 22c8d9c735..d0cfd76fae 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt @@ -90,7 +90,6 @@ class DeveloperSettingsPresenter( LaunchedEffect(Unit) { featureFlagService.getAvailableFeatures() - .filter { it.isInLabs.not() && it.isFinished.not() } .run { // Never display room directory search in release builds for Play Store if (buildMeta.flavorDescription == "GooglePlay" && buildMeta.buildType == BuildType.RELEASE) { diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/labs/LabsPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/labs/LabsPresenter.kt index 5e74454d75..b1e3fc7b77 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/labs/LabsPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/labs/LabsPresenter.kt @@ -43,8 +43,7 @@ class LabsPresenter( override fun present(): LabsState { val coroutineScope = rememberCoroutineScope() val features = remember { - val entries = featureFlagService.getAvailableFeatures() - .filter { it.isInLabs && !it.isFinished } + val entries = featureFlagService.getAvailableFeatures(isInLabs = true) .map { it.key to it } mutableStateMapOf(*entries.toTypedArray()) } 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 3da72f982e..2a8eeaea1f 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 @@ -112,7 +112,7 @@ class PreferencesRootPresenter( .launchIn(this) } - val showLabsItem = remember { featureFlagService.getAvailableFeatures().any { it.isInLabs && !it.isFinished } } + val showLabsItem = remember { featureFlagService.getAvailableFeatures(isInLabs = true).isNotEmpty() } val directLogoutState = directLogoutPresenter.present() diff --git a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlagService.kt b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlagService.kt index 1358909771..c6319cc03b 100644 --- a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlagService.kt +++ b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlagService.kt @@ -35,7 +35,12 @@ interface FeatureFlagService { suspend fun setFeatureEnabled(feature: Feature, enabled: Boolean): Boolean /** - * @return the list of available (not finished) features that can be toggled. + * @return the list of available features that can be toggled. + * @param includeFinishFeatures whether to include finished features, default is false + * @param isInLabs whether the user is in labs (to include lab features), default is false */ - fun getAvailableFeatures(): List + fun getAvailableFeatures( + includeFinishFeatures: Boolean = false, + isInLabs: Boolean = false, + ): List } diff --git a/libraries/featureflag/impl/src/main/kotlin/io/element/android/libraries/featureflag/impl/DefaultFeatureFlagService.kt b/libraries/featureflag/impl/src/main/kotlin/io/element/android/libraries/featureflag/impl/DefaultFeatureFlagService.kt index a7ff8c09dd..dca114f5d8 100644 --- a/libraries/featureflag/impl/src/main/kotlin/io/element/android/libraries/featureflag/impl/DefaultFeatureFlagService.kt +++ b/libraries/featureflag/impl/src/main/kotlin/io/element/android/libraries/featureflag/impl/DefaultFeatureFlagService.kt @@ -40,7 +40,13 @@ class DefaultFeatureFlagService( ?: false } - override fun getAvailableFeatures(): List { - return FeatureFlags.entries.filter { !it.isFinished } + override fun getAvailableFeatures( + includeFinishFeatures: Boolean, + isInLabs: Boolean, + ): List { + return FeatureFlags.entries.filter { flag -> + (includeFinishFeatures || !flag.isFinished) && + flag.isInLabs == isInLabs + } } } diff --git a/libraries/featureflag/test/src/main/java/io/element/android/libraries/featureflag/test/FakeFeatureFlagService.kt b/libraries/featureflag/test/src/main/java/io/element/android/libraries/featureflag/test/FakeFeatureFlagService.kt index 49fc095ed4..88a4941da1 100644 --- a/libraries/featureflag/test/src/main/java/io/element/android/libraries/featureflag/test/FakeFeatureFlagService.kt +++ b/libraries/featureflag/test/src/main/java/io/element/android/libraries/featureflag/test/FakeFeatureFlagService.kt @@ -33,7 +33,10 @@ class FakeFeatureFlagService( return enabledFeatures.getOrPut(feature.key) { MutableStateFlow(feature.defaultValue(buildMeta)) } } - override fun getAvailableFeatures(): List { + override fun getAvailableFeatures( + includeFinishFeatures: Boolean, + isInLabs: Boolean, + ): List { return providedAvailableFeatures } }