Skip to content

Commit

Permalink
Update InsightsManagementMapper.kt
Browse files Browse the repository at this point in the history
Remove Today Stats from Insights when TrafficTab is enabled
  • Loading branch information
ravishanker committed Feb 22, 2024
1 parent 2440e07 commit 8c2c169
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel.Status.ADDED
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel.Status.REMOVED
import org.wordpress.android.ui.utils.ListItemInteraction
import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig
import javax.inject.Inject
import javax.inject.Named

Expand All @@ -47,17 +48,23 @@ private val ACTIVITY_INSIGHTS = mutableListOf(
private val GENERAL_INSIGHTS = mutableListOf(
ALL_TIME_STATS,
MOST_POPULAR_DAY_AND_HOUR,
ANNUAL_SITE_STATS,
TODAY_STATS
ANNUAL_SITE_STATS
)

class InsightsManagementMapper @Inject constructor(
@Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher
@Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher,
private val trafficTabFeatureConfig: StatsTrafficTabFeatureConfig
) {
suspend fun buildUIModel(addedTypes: Set<InsightType>, onClick: (InsightType) -> Unit) =
withContext(bgDispatcher) {
val insightListItems = mutableListOf<InsightListItem>()
insightListItems += Header(R.string.stats_insights_management_general)
if (BuildConfig.IS_JETPACK_APP &&
!trafficTabFeatureConfig.isEnabled() &&
!GENERAL_INSIGHTS.contains(TODAY_STATS)
) {
GENERAL_INSIGHTS.add(TODAY_STATS)
}
if (BuildConfig.IS_JETPACK_APP && !GENERAL_INSIGHTS.contains(VIEWS_AND_VISITORS)) {
GENERAL_INSIGHTS.add(0, VIEWS_AND_VISITORS)
}
Expand Down

0 comments on commit 8c2c169

Please sign in to comment.