Skip to content

Commit 82a97eb

Browse files
committed
Make TRAFFIC tab default
1 parent 1a67bc0 commit 82a97eb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManager.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ import org.wordpress.android.fluxc.network.utils.StatsGranularity.WEEKS
1111
import org.wordpress.android.fluxc.network.utils.StatsGranularity.YEARS
1212
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection
1313
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection.INSIGHTS
14+
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection.TRAFFIC
15+
import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig
1416
import javax.inject.Inject
1517

1618
const val SELECTED_SECTION_KEY = "SELECTED_STATS_SECTION_KEY"
1719

1820
class SelectedSectionManager
19-
@Inject constructor(private val sharedPrefs: SharedPreferences) {
21+
@Inject constructor(
22+
private val sharedPrefs: SharedPreferences,
23+
private val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig
24+
) {
2025
private val _liveSelectedSection = MutableLiveData<StatsSection>()
2126
val liveSelectedSection: LiveData<StatsSection>
2227
get() {
@@ -28,7 +33,8 @@ class SelectedSectionManager
2833
}
2934

3035
fun getSelectedSection(): StatsSection {
31-
val value = sharedPrefs.getString(SELECTED_SECTION_KEY, INSIGHTS.name)
36+
val defaultValue = if (statsTrafficTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS
37+
val value = sharedPrefs.getString(SELECTED_SECTION_KEY, defaultValue.name)
3238
return value?.let { StatsSection.valueOf(value) } ?: INSIGHTS
3339
}
3440

0 commit comments

Comments
 (0)