Skip to content

Commit

Permalink
Update StatsViewModel.kt
Browse files Browse the repository at this point in the history
handle deeplink granularity
  • Loading branch information
ravishanker committed Feb 28, 2024
1 parent 3a12b87 commit 7c02ba5
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,20 @@ class StatsViewModel
}

private fun getInitialTimeFrame(intent: Intent): StatsSection? {
return when (intent.getSerializableExtraCompat<Serializable>(StatsActivity.ARG_DESIRED_TIMEFRAME)) {
val timeframe = intent.getSerializableExtraCompat<StatsTimeframe>(StatsActivity.ARG_DESIRED_TIMEFRAME)
if (statsTrafficTabFeatureConfig.isEnabled()) {
if (timeframe == DAY || timeframe == WEEK || timeframe == MONTH || timeframe == YEAR) {
when (timeframe) {
DAY -> selectedTrafficGranularityManager.setSelectedTrafficGranularity(StatsGranularity.DAYS)
WEEK -> selectedTrafficGranularityManager.setSelectedTrafficGranularity(StatsGranularity.WEEKS)
MONTH -> selectedTrafficGranularityManager.setSelectedTrafficGranularity(StatsGranularity.MONTHS)
YEAR -> selectedTrafficGranularityManager.setSelectedTrafficGranularity(StatsGranularity.YEARS)
else -> { /* Do nothing */}
}
}
}

return when (timeframe) {
StatsTimeframe.INSIGHTS -> StatsSection.INSIGHTS
DAY -> StatsSection.DAYS
WEEK -> StatsSection.WEEKS
Expand Down

0 comments on commit 7c02ba5

Please sign in to comment.