mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
No issue: Use ExcludeTypes instead of filtering after retrieving
This commit is contained in:
parent
a02bf550c8
commit
40f8e3b6af
@ -232,23 +232,27 @@ class HistoryFragment : Fragment(), CoroutineScope, BackHandler {
|
|||||||
override fun onBackPressed(): Boolean = (historyComponent.uiView as HistoryUIView).onBackPressed()
|
override fun onBackPressed(): Boolean = (historyComponent.uiView as HistoryUIView).onBackPressed()
|
||||||
|
|
||||||
private suspend fun reloadData() {
|
private suspend fun reloadData() {
|
||||||
val allowedVisitTypes = listOf(VisitType.LINK, VisitType.TYPED, VisitType.BOOKMARK)
|
val excludeTypes = listOf(
|
||||||
|
VisitType.NOT_A_VISIT,
|
||||||
|
VisitType.DOWNLOAD,
|
||||||
|
VisitType.REDIRECT_TEMPORARY,
|
||||||
|
VisitType.RELOAD,
|
||||||
|
VisitType.EMBED,
|
||||||
|
VisitType.FRAMED_LINK,
|
||||||
|
VisitType.REDIRECT_PERMANENT
|
||||||
|
)
|
||||||
// Until we have proper pagination, only display a limited set of history to avoid blowing up the UI.
|
// Until we have proper pagination, only display a limited set of history to avoid blowing up the UI.
|
||||||
// See https://github.com/mozilla-mobile/fenix/issues/1393
|
// See https://github.com/mozilla-mobile/fenix/issues/1393
|
||||||
@SuppressWarnings("MagicNumber")
|
@SuppressWarnings("MagicNumber")
|
||||||
val historyCutoffMs = 1000L * 60 * 60 * 24 * 3 // past few days
|
val historyCutoffMs = 1000L * 60 * 60 * 24 * 3 // past few days
|
||||||
val items = requireComponents.core.historyStorage.getDetailedVisits(
|
val items = requireComponents.core.historyStorage.getDetailedVisits(
|
||||||
System.currentTimeMillis() - historyCutoffMs
|
System.currentTimeMillis() - historyCutoffMs, excludeTypes = excludeTypes
|
||||||
)
|
)
|
||||||
// We potentially have a large amount of visits, and multiple processing steps.
|
// We potentially have a large amount of visits, and multiple processing steps.
|
||||||
// Wrapping iterator in a sequence should make this a little more efficient.
|
// Wrapping iterator in a sequence should make this a little more efficient.
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.sortedByDescending { it.visitTime }
|
.sortedByDescending { it.visitTime }
|
||||||
|
|
||||||
// Temporary filtering until we can do it at the API level.
|
|
||||||
// See https://github.com/mozilla-mobile/android-components/issues/2643
|
|
||||||
.filter { allowedVisitTypes.contains(it.visitType) }
|
|
||||||
|
|
||||||
.mapIndexed { id, item ->
|
.mapIndexed { id, item ->
|
||||||
HistoryItem(
|
HistoryItem(
|
||||||
id, if (TextUtils.isEmpty(item.title!!)) try {
|
id, if (TextUtils.isEmpty(item.title!!)) try {
|
||||||
|
Loading…
Reference in New Issue
Block a user