Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change FeatureFlagService.isFeatureEnabled return value from Boolean to Flow<Boolean> #1703

Merged
merged 2 commits into from
Oct 31, 2023

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 31, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Change FeatureFlagService.isFeatureEnabled return value from Boolean to Flow

Motivation and context

Be able to have "live" behavior of feature flag. Until now this was not necessary because when user goes to the settings to switch a flag, the flag is read again when entering the screen where the flag has an effect. Ex: Timeline.

But without this, it would be a bit harder (yet not impossible) to have a flag that have effect on the room list for instance, since the settings screen is a subscreen of the room list.

In particular, we will need this to be able to add a feature flag for the key backup. A banner can be displayed on the room list.

Screenshots / GIFs

NA

Tests

  • Play with the feature flags and check that the effect are still working as expected.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from a team as a code owner October 31, 2023 10:45
@bmarty bmarty requested review from julioromano and removed request for a team October 31, 2023 10:45
@@ -33,3 +36,6 @@ interface FeatureFlagService {
*/
suspend fun setFeatureEnabled(feature: Feature, enabled: Boolean): Boolean
}

suspend fun FeatureFlagService.isFeatureEnabled(feature: Feature): Boolean =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a handy extension to avoid touching the code too much.

@bmarty bmarty force-pushed the feature/bma/featureFlagFlow branch from 13a4fac to d6820d8 Compare October 31, 2023 10:46
@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/h2Af4b

@bmarty bmarty force-pushed the feature/bma/featureFlagFlow branch from d6820d8 to 1e0dd49 Compare October 31, 2023 12:14
override suspend fun isFeatureEnabled(feature: Feature): Boolean {
return if (feature is FeatureFlags) {
when(feature) {
override suspend fun isFeatureEnabledFlow(feature: Feature): Flow<Boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suspend here shall be removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated.

@@ -33,3 +36,6 @@ interface FeatureFlagService {
*/
suspend fun setFeatureEnabled(feature: Feature, enabled: Boolean): Boolean
}

suspend fun FeatureFlagService.isFeatureEnabled(feature: Feature): Boolean =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it a breaking change.
If you kept this API as it was and added the flow variant to the interface, it would be an "addition only change" and hence non-breaking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I have updated the PR.

Copy link

sonarcloud bot commented Oct 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@bmarty bmarty merged commit 89e7ff4 into develop Oct 31, 2023
14 checks passed
@bmarty bmarty deleted the feature/bma/featureFlagFlow branch October 31, 2023 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants