switch to top recent sites
This commit is contained in:
+30
-1
@@ -2,8 +2,10 @@ package eu.weblibre.flutter_mozilla_components.api
|
||||
|
||||
import eu.weblibre.flutter_mozilla_components.GlobalComponents
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoHistoryApi
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.FrecencyThresholdOption
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.HistoryHighlight
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.HistoryHighlightWeights
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.TopFrecentSiteInfo
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.VisitInfo
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.VisitType
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -236,4 +238,31 @@ class GeckoHistoryApiImpl() : GeckoHistoryApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTopFrecentSites(
|
||||
limit: Long,
|
||||
frecencyThreshold: FrecencyThresholdOption,
|
||||
callback: (Result<List<TopFrecentSiteInfo>>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
val conceptThreshold = when (frecencyThreshold) {
|
||||
FrecencyThresholdOption.NONE ->
|
||||
mozilla.components.concept.storage.FrecencyThresholdOption.NONE
|
||||
FrecencyThresholdOption.SKIP_ONE_TIME_PAGES ->
|
||||
mozilla.components.concept.storage.FrecencyThresholdOption.SKIP_ONE_TIME_PAGES
|
||||
}
|
||||
val sites = components.core.historyStorage.getTopFrecentSites(
|
||||
limit.toInt(),
|
||||
conceptThreshold,
|
||||
).map {
|
||||
TopFrecentSiteInfo(
|
||||
url = it.url,
|
||||
title = it.title,
|
||||
)
|
||||
}
|
||||
callback(Result.success(sites))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+281
-199
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user