Skip to content

Commit

Permalink
Make TRAFFIC tab default
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano committed Mar 2, 2024
1 parent 1a67bc0 commit 82a97eb
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import org.wordpress.android.fluxc.network.utils.StatsGranularity.WEEKS
import org.wordpress.android.fluxc.network.utils.StatsGranularity.YEARS
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection.INSIGHTS
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection.TRAFFIC
import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig
import javax.inject.Inject

const val SELECTED_SECTION_KEY = "SELECTED_STATS_SECTION_KEY"

class SelectedSectionManager
@Inject constructor(private val sharedPrefs: SharedPreferences) {
@Inject constructor(
private val sharedPrefs: SharedPreferences,
private val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig
) {
private val _liveSelectedSection = MutableLiveData<StatsSection>()
val liveSelectedSection: LiveData<StatsSection>
get() {
Expand All @@ -28,7 +33,8 @@ class SelectedSectionManager
}

fun getSelectedSection(): StatsSection {
val value = sharedPrefs.getString(SELECTED_SECTION_KEY, INSIGHTS.name)
val defaultValue = if (statsTrafficTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS
val value = sharedPrefs.getString(SELECTED_SECTION_KEY, defaultValue.name)
return value?.let { StatsSection.valueOf(value) } ?: INSIGHTS
}

Expand Down

0 comments on commit 82a97eb

Please sign in to comment.