Make a diff between FeatureFlags.defaultValue and value returned by StaticFeatureFlagProvider.isFeatureEnabled().

Iterate after Ganfra's review.
This commit is contained in:
Benoit Marty 2023-09-07 12:32:21 +02:00
parent 94407d396b
commit 952ca1a143
2 changed files with 9 additions and 3 deletions

View file

@ -18,7 +18,8 @@ package io.element.android.libraries.featureflag.api
/** /**
* To enable or disable a FeatureFlags, change the `defaultValue` value. * To enable or disable a FeatureFlags, change the `defaultValue` value.
* It will impact all the build types. * Warning: to enable a flog for the release app, you MUST update the file
* [io.element.android.libraries.featureflag.impl.StaticFeatureFlagProvider]
*/ */
enum class FeatureFlags( enum class FeatureFlags(
override val key: String, override val key: String,
@ -40,6 +41,7 @@ enum class FeatureFlags(
NotificationSettings( NotificationSettings(
key = "feature.notificationsettings", key = "feature.notificationsettings",
title = "Show notification settings", title = "Show notification settings",
// Do not forget to edit StaticFeatureFlagProvider when enabling the feature.
defaultValue = false, defaultValue = false,
), ),
} }

View file

@ -22,7 +22,7 @@ import javax.inject.Inject
/** /**
* This provider is used for release build. * This provider is used for release build.
* [isFeatureEnabled] just returns the default value of the FeatureFlags. * This is the place to enable or disable feature for the release build.
*/ */
class StaticFeatureFlagProvider @Inject constructor() : class StaticFeatureFlagProvider @Inject constructor() :
FeatureFlagProvider { FeatureFlagProvider {
@ -31,7 +31,11 @@ class StaticFeatureFlagProvider @Inject constructor() :
override suspend fun isFeatureEnabled(feature: Feature): Boolean { override suspend fun isFeatureEnabled(feature: Feature): Boolean {
return if (feature is FeatureFlags) { return if (feature is FeatureFlags) {
feature.defaultValue when(feature) {
FeatureFlags.LocationSharing -> true
FeatureFlags.Polls -> true
FeatureFlags.NotificationSettings -> false
}
} else { } else {
false false
} }