mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
FFs can now be toggled in release builds too (#3101)
- Removed `StaticFeatureFlagProvider`. - Always provide `PreferencesFeatureFlagProvider`. - For the default values of feature flags, use a lambda with a `BuildMeta` parameter so we can customize the return value based on its data.
This commit is contained in:
committed by
GitHub
parent
4757aac8b8
commit
32a374d836
@@ -23,6 +23,8 @@ android {
|
||||
|
||||
dependencies {
|
||||
api(projects.libraries.featureflag.api)
|
||||
implementation(projects.libraries.core)
|
||||
implementation(projects.libraries.matrix.test)
|
||||
implementation(libs.coroutines.core)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -16,19 +16,19 @@
|
||||
|
||||
package io.element.android.libraries.featureflag.test
|
||||
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import io.element.android.libraries.featureflag.api.Feature
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
class FakeFeatureFlagService(
|
||||
initialState: Map<String, Boolean> = emptyMap()
|
||||
initialState: Map<String, Boolean> = emptyMap(),
|
||||
private val buildMeta: BuildMeta = aBuildMeta(),
|
||||
) : FeatureFlagService {
|
||||
private val enabledFeatures = initialState
|
||||
.map {
|
||||
it.key to MutableStateFlow(it.value)
|
||||
}
|
||||
.toMap()
|
||||
.mapValues { MutableStateFlow(it.value) }
|
||||
.toMutableMap()
|
||||
|
||||
override suspend fun setFeatureEnabled(feature: Feature, enabled: Boolean): Boolean {
|
||||
@@ -38,6 +38,6 @@ class FakeFeatureFlagService(
|
||||
}
|
||||
|
||||
override fun isFeatureEnabledFlow(feature: Feature): Flow<Boolean> {
|
||||
return enabledFeatures.getOrPut(feature.key) { MutableStateFlow(feature.defaultValue) }
|
||||
return enabledFeatures.getOrPut(feature.key) { MutableStateFlow(feature.defaultValue(buildMeta)) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user