Skip to content

Commit b341691

Browse files
committed
Add tracker animation tile conditionally based on tracker count
We only show if you have 10 trackers or more Next we'll check the tab count
1 parent b022ef8 commit b341691

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModel.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,21 @@ class TabSwitcherViewModel @Inject constructor(
248248
) {
249249
tabSwitcherPrefsDataStore.isAnimationTileDismissed().collect { isDismissed ->
250250
val tabItems = tabEntities.map { Tab(it) }
251+
val trackerCount = getTrackerCountForLast7Days()
251252

252-
val tabSwitcherItems = if (!isDismissed) {
253-
listOf(createTrackerAnimationTile()) + tabItems
253+
val tabSwitcherItems = if (!isDismissed && trackerCount >= 10) {
254+
listOf(TrackerAnimationTile(trackerCount)) + tabItems
254255
} else {
255256
tabItems
256257
}
257258
emit(tabSwitcherItems)
258259
}
259260
}
261+
262+
private suspend fun getTrackerCountForLast7Days(): Int {
263+
return webTrackersBlockedAppRepository.getTrackersCountBetween(
264+
startTime = LocalDateTime.now().minusDays(7),
265+
endTime = LocalDateTime.now(),
266+
)
267+
}
260268
}

0 commit comments

Comments
 (0)