Fix toggling 'show all activity in room list' not working (#7871)

Toggling this value had no effect because the feature was marked as finished so it wouldn't be displayed in the developer settings, which makes our code ignore any user-set value for it.

Instead, just create a `Feature` outside the `FeatureFlags` enum.
This commit is contained in:
Jorge Martin Espinosa
2026-10-07 10:09:25 +02:00
committed by GitHub
parent 03ea0ecc27
commit 3944cb3bfc
8 changed files with 35 additions and 27 deletions
@@ -47,6 +47,7 @@ import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.featureflag.api.FeatureFlagService
import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.featureflag.api.ShowAllActivityInRoomListFeature
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.matrix.api.core.RoomId
@@ -119,7 +120,7 @@ class RoomListPresenter(
val declineInviteMenu = remember { mutableStateOf<RoomListState.DeclineInviteMenu>(RoomListState.DeclineInviteMenu.Hidden) }
val showAllActivity by produceState(initialValue = false) {
featureFlagService.isFeatureEnabledFlow(FeatureFlags.ShowAllActivityInRoomList).collect { value = it }
featureFlagService.isFeatureEnabledFlow(ShowAllActivityInRoomListFeature).collect { value = it }
}
fun handleEvent(event: RoomListEvent) {
@@ -40,6 +40,7 @@ import io.element.android.libraries.eventformatter.api.RoomLatestEventFormatter
import io.element.android.libraries.eventformatter.test.FakeRoomLatestEventFormatter
import io.element.android.libraries.featureflag.api.FeatureFlagService
import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.featureflag.api.ShowAllActivityInRoomListFeature
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
import io.element.android.libraries.fullscreenintent.api.aFullScreenIntentPermissionsState
import io.element.android.libraries.matrix.api.MatrixClient
@@ -655,7 +656,7 @@ class RoomListPresenterTest {
)
val featureFlagService = FakeFeatureFlagService(
initialState = mapOf(
FeatureFlags.ShowAllActivityInRoomList.key to true,
ShowAllActivityInRoomListFeature.key to true,
FeatureFlags.UnreadIndicatorCount.key to true,
)
)
@@ -672,7 +673,7 @@ class RoomListPresenterTest {
assertThat(enabledState.contentAsRooms().showAllActivity).isTrue()
assertThat(enabledState.contentAsRooms().showUnreadCount).isTrue()
featureFlagService.setFeatureEnabled(FeatureFlags.ShowAllActivityInRoomList, false)
featureFlagService.setFeatureEnabled(ShowAllActivityInRoomListFeature, false)
val allActivityDisabledState = consumeItemsUntilPredicate { state ->
state.contentState is RoomListContentState.Rooms && !state.contentAsRooms().showAllActivity
}.last()
@@ -34,5 +34,5 @@ sealed interface NotificationSettingsEvent {
data object DismissCallRingtoneDialog : NotificationSettingsEvent
data class SelectCallRingtonePreset(val sound: NotificationSound) : NotificationSettingsEvent
data object LaunchCallRingtonePicker : NotificationSettingsEvent
data object ToggleShowAllActivityInRoomList : NotificationSettingsEvent
data class ToggleShowAllActivityInRoomList(val newValue: Boolean) : NotificationSettingsEvent
}
@@ -29,7 +29,7 @@ import io.element.android.libraries.architecture.runUpdatingStateNoSuccess
import io.element.android.libraries.core.extensions.runCatchingExceptions
import io.element.android.libraries.di.annotations.SessionCoroutineScope
import io.element.android.libraries.featureflag.api.FeatureFlagService
import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.featureflag.api.ShowAllActivityInRoomListFeature
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.matrix.api.notificationsettings.NotificationSettingsService
@@ -200,7 +200,7 @@ class NotificationSettingsPresenter(
}
val showAllActivityInRoomList by produceState(false) {
featureFlagService.isFeatureEnabledFlow(FeatureFlags.ShowAllActivityInRoomList)
featureFlagService.isFeatureEnabledFlow(ShowAllActivityInRoomListFeature)
.collect { value = it }
}
@@ -284,8 +284,8 @@ class NotificationSettingsPresenter(
NotificationSettingsEvent.DismissCallRingtoneCopyError -> {
callRingtoneCopyError = false
}
NotificationSettingsEvent.ToggleShowAllActivityInRoomList -> localCoroutineScope.launch {
featureFlagService.setFeatureEnabled(FeatureFlags.ShowAllActivityInRoomList, !showAllActivityInRoomList)
is NotificationSettingsEvent.ToggleShowAllActivityInRoomList -> localCoroutineScope.launch {
featureFlagService.setFeatureEnabled(ShowAllActivityInRoomListFeature, event.newValue)
}
}
}
@@ -205,7 +205,7 @@ private fun NotificationSettingsContentView(
title = stringResource(R.string.screen_notification_settings_show_all_activity_title),
subtitle = stringResource(R.string.screen_notification_settings_show_all_activity_subtitle),
isChecked = state.showAllActivityInRoomList,
onCheckedChange = { state.eventSink(NotificationSettingsEvent.ToggleShowAllActivityInRoomList) }
onCheckedChange = { newValue -> state.eventSink(NotificationSettingsEvent.ToggleShowAllActivityInRoomList(newValue)) }
)
}
@@ -11,7 +11,7 @@ package io.element.android.features.preferences.impl.notifications
import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.featureflag.api.FeatureFlagService
import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.featureflag.api.ShowAllActivityInRoomListFeature
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
import io.element.android.libraries.fullscreenintent.api.aFullScreenIntentPermissionsState
@@ -1110,13 +1110,13 @@ class NotificationSettingsPresenterTest {
@Test
fun `present - showAllActivityInRoomList reflects the feature flag value`() = runTest {
val featureFlagService = FakeFeatureFlagService(
initialState = mapOf(FeatureFlags.ShowAllActivityInRoomList.key to true)
initialState = mapOf(ShowAllActivityInRoomListFeature.key to true)
)
val presenter = createNotificationSettingsPresenter(featureFlagService = featureFlagService)
presenter.test {
val state = consumeItemsUntilPredicate { it.showAllActivityInRoomList }.last()
assertThat(state.showAllActivityInRoomList).isTrue()
featureFlagService.setFeatureEnabled(FeatureFlags.ShowAllActivityInRoomList, false)
featureFlagService.setFeatureEnabled(ShowAllActivityInRoomListFeature, false)
val updatedState = consumeItemsUntilPredicate { !it.showAllActivityInRoomList }.last()
assertThat(updatedState.showAllActivityInRoomList).isFalse()
@@ -1127,22 +1127,22 @@ class NotificationSettingsPresenterTest {
@Test
fun `present - ToggleShowAllActivityInRoomList toggles the feature flag`() = runTest {
val featureFlagService = FakeFeatureFlagService(
initialState = mapOf(FeatureFlags.ShowAllActivityInRoomList.key to false)
initialState = mapOf(ShowAllActivityInRoomListFeature.key to false)
)
val presenter = createNotificationSettingsPresenter(featureFlagService = featureFlagService)
presenter.test {
val initialState = awaitItem()
assertThat(initialState.showAllActivityInRoomList).isFalse()
initialState.eventSink(NotificationSettingsEvent.ToggleShowAllActivityInRoomList)
initialState.eventSink(NotificationSettingsEvent.ToggleShowAllActivityInRoomList(true))
val enabledState = consumeItemsUntilPredicate { it.showAllActivityInRoomList }.last()
assertThat(enabledState.showAllActivityInRoomList).isTrue()
assertThat(featureFlagService.isFeatureEnabled(FeatureFlags.ShowAllActivityInRoomList)).isTrue()
enabledState.eventSink(NotificationSettingsEvent.ToggleShowAllActivityInRoomList)
assertThat(featureFlagService.isFeatureEnabled(ShowAllActivityInRoomListFeature)).isTrue()
enabledState.eventSink(NotificationSettingsEvent.ToggleShowAllActivityInRoomList(false))
val disabledState = consumeItemsUntilPredicate { !it.showAllActivityInRoomList }.last()
assertThat(disabledState.showAllActivityInRoomList).isFalse()
assertThat(featureFlagService.isFeatureEnabled(FeatureFlags.ShowAllActivityInRoomList)).isFalse()
assertThat(featureFlagService.isFeatureEnabled(ShowAllActivityInRoomListFeature)).isFalse()
cancelAndIgnoreRemainingEvents()
}
}
@@ -207,7 +207,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
eventsRecorder.assertList(
listOf(
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
NotificationSettingsEvent.ToggleShowAllActivityInRoomList,
NotificationSettingsEvent.ToggleShowAllActivityInRoomList(!initialState),
)
)
}