mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
For #20893: Dedupe urls/site in history groups
This commit is contained in:
parent
976dd6ebe1
commit
d830006984
@ -132,10 +132,14 @@ class DefaultPagedHistoryProvider(
|
|||||||
// item.
|
// item.
|
||||||
result.addAll(history.filter { item -> historyMetadata.find { it.url == item.url } == null })
|
result.addAll(history.filter { item -> historyMetadata.find { it.url == item.url } == null })
|
||||||
|
|
||||||
// Filter history metadata items with no view time.
|
// Filter history metadata items with no view time and dedupe by url.
|
||||||
|
// Note that distinctBy is sufficient here as it keeps the order of the source
|
||||||
|
// collection, and we're only sorting by visitedAt (=updatedAt) currently.
|
||||||
|
// If we needed the view time we'd have to aggregate it for entries with the same
|
||||||
|
// url, but we don't have a use case for this currently in the history view.
|
||||||
result.addAll(
|
result.addAll(
|
||||||
historyGroupsInOffset.map { group ->
|
historyGroupsInOffset.map { group ->
|
||||||
group.copy(items = group.items.filter { it.totalViewTime > 0 })
|
group.copy(items = group.items.filter { it.totalViewTime > 0 }.distinctBy { it.url })
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,8 +73,20 @@ class PagedHistoryProviderTest {
|
|||||||
previewImageUrl = null
|
previewImageUrl = null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Adding a third entry with same url to test deduping
|
||||||
|
val historyMetadataKey3 = HistoryMetadataKey("http://www.firefox.com", "mozilla", null)
|
||||||
|
val historyEntry3 = HistoryMetadata(
|
||||||
|
key = historyMetadataKey3,
|
||||||
|
title = "firefox",
|
||||||
|
createdAt = 3,
|
||||||
|
updatedAt = 3,
|
||||||
|
totalViewTime = 30,
|
||||||
|
documentType = DocumentType.Regular,
|
||||||
|
previewImageUrl = null
|
||||||
|
)
|
||||||
|
|
||||||
coEvery { storage.getVisitsPaginated(any(), any(), any()) } returns listOf(visitInfo1, visitInfo2, visitInfo3)
|
coEvery { storage.getVisitsPaginated(any(), any(), any()) } returns listOf(visitInfo1, visitInfo2, visitInfo3)
|
||||||
coEvery { storage.getHistoryMetadataSince(any()) } returns listOf(historyEntry1, historyEntry2)
|
coEvery { storage.getHistoryMetadataSince(any()) } returns listOf(historyEntry1, historyEntry2, historyEntry3)
|
||||||
|
|
||||||
var actualResults: List<History>? = null
|
var actualResults: List<History>? = null
|
||||||
provider.getHistory(10L, 5) {
|
provider.getHistory(10L, 5) {
|
||||||
|
Loading…
Reference in New Issue
Block a user