mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
[fenix] No issue: clean up code duplication in PagedHistoryProvider
This commit is contained in:
parent
5e486fa6b6
commit
6f1ba6ca6b
@ -37,6 +37,18 @@ class DefaultPagedHistoryProvider(
|
||||
private val historyStorage: PlacesHistoryStorage,
|
||||
private val showHistorySearchGroups: Boolean = FeatureFlags.showHistorySearchGroups,
|
||||
) : PagedHistoryProvider {
|
||||
/**
|
||||
* Types of visits we currently do not display in the History UI.
|
||||
*/
|
||||
private val excludedVisitTypes = listOf(
|
||||
VisitType.NOT_A_VISIT,
|
||||
VisitType.DOWNLOAD,
|
||||
VisitType.REDIRECT_PERMANENT,
|
||||
VisitType.REDIRECT_TEMPORARY,
|
||||
VisitType.RELOAD,
|
||||
VisitType.EMBED,
|
||||
VisitType.FRAMED_LINK,
|
||||
)
|
||||
|
||||
@Volatile private var historyGroups: List<History.Group>? = null
|
||||
|
||||
@ -75,15 +87,7 @@ class DefaultPagedHistoryProvider(
|
||||
.getVisitsPaginated(
|
||||
offset,
|
||||
numberOfItems,
|
||||
excludeTypes = listOf(
|
||||
VisitType.NOT_A_VISIT,
|
||||
VisitType.DOWNLOAD,
|
||||
VisitType.REDIRECT_TEMPORARY,
|
||||
VisitType.RELOAD,
|
||||
VisitType.EMBED,
|
||||
VisitType.FRAMED_LINK,
|
||||
VisitType.REDIRECT_PERMANENT
|
||||
)
|
||||
excludeTypes = excludedVisitTypes
|
||||
)
|
||||
.mapIndexed(transformVisitInfoToHistoryItem(offset.toInt()))
|
||||
}
|
||||
@ -102,15 +106,7 @@ class DefaultPagedHistoryProvider(
|
||||
val history = historyStorage.getDetailedVisits(
|
||||
start = historyMetadata.visitedAt - BUFFER_TIME,
|
||||
end = historyMetadata.visitedAt + BUFFER_TIME,
|
||||
excludeTypes = listOf(
|
||||
VisitType.NOT_A_VISIT,
|
||||
VisitType.DOWNLOAD,
|
||||
VisitType.REDIRECT_TEMPORARY,
|
||||
VisitType.RELOAD,
|
||||
VisitType.EMBED,
|
||||
VisitType.FRAMED_LINK,
|
||||
VisitType.REDIRECT_PERMANENT
|
||||
)
|
||||
excludeTypes = excludedVisitTypes
|
||||
)
|
||||
return history
|
||||
.filter { it.url == historyMetadata.url }
|
||||
@ -134,15 +130,7 @@ class DefaultPagedHistoryProvider(
|
||||
.getVisitsPaginated(
|
||||
offset,
|
||||
numberOfItems,
|
||||
excludeTypes = listOf(
|
||||
VisitType.NOT_A_VISIT,
|
||||
VisitType.DOWNLOAD,
|
||||
VisitType.REDIRECT_TEMPORARY,
|
||||
VisitType.RELOAD,
|
||||
VisitType.EMBED,
|
||||
VisitType.FRAMED_LINK,
|
||||
VisitType.REDIRECT_PERMANENT
|
||||
)
|
||||
excludeTypes = excludedVisitTypes
|
||||
)
|
||||
.mapIndexed(transformVisitInfoToHistoryItem(offset.toInt()))
|
||||
|
||||
|
@ -103,11 +103,11 @@ class PagedHistoryProviderTest {
|
||||
excludeTypes = listOf(
|
||||
VisitType.NOT_A_VISIT,
|
||||
VisitType.DOWNLOAD,
|
||||
VisitType.REDIRECT_PERMANENT,
|
||||
VisitType.REDIRECT_TEMPORARY,
|
||||
VisitType.RELOAD,
|
||||
VisitType.EMBED,
|
||||
VisitType.FRAMED_LINK,
|
||||
VisitType.REDIRECT_PERMANENT
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -189,11 +189,11 @@ class PagedHistoryProviderTest {
|
||||
excludeTypes = listOf(
|
||||
VisitType.NOT_A_VISIT,
|
||||
VisitType.DOWNLOAD,
|
||||
VisitType.REDIRECT_PERMANENT,
|
||||
VisitType.REDIRECT_TEMPORARY,
|
||||
VisitType.RELOAD,
|
||||
VisitType.EMBED,
|
||||
VisitType.FRAMED_LINK,
|
||||
VisitType.REDIRECT_PERMANENT
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -262,11 +262,11 @@ class PagedHistoryProviderTest {
|
||||
excludeTypes = listOf(
|
||||
VisitType.NOT_A_VISIT,
|
||||
VisitType.DOWNLOAD,
|
||||
VisitType.REDIRECT_PERMANENT,
|
||||
VisitType.REDIRECT_TEMPORARY,
|
||||
VisitType.RELOAD,
|
||||
VisitType.EMBED,
|
||||
VisitType.FRAMED_LINK,
|
||||
VisitType.REDIRECT_PERMANENT
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user