|
|
@ -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 {
|
|
|
|