add getVisitsPaginated; disable onScrollChange
This commit is contained in:
+70
-5
@@ -26,8 +26,9 @@ class GeckoHistoryApiImpl() : GeckoHistoryApi {
|
||||
endMillis: Long,
|
||||
): List<VisitInfo> =
|
||||
values
|
||||
.filter { isDisplayableItem(it.status) &&
|
||||
it.createdTime >= startMillis && it.createdTime <= endMillis
|
||||
.filter {
|
||||
isDisplayableItem(it.status) &&
|
||||
it.createdTime >= startMillis && it.createdTime <= endMillis
|
||||
}
|
||||
.distinctBy { Pair(it.fileName, it.status) }
|
||||
.sortedByDescending { it.createdTime } // sort from newest to oldest
|
||||
@@ -92,11 +93,75 @@ class GeckoHistoryApiImpl() : GeckoHistoryApi {
|
||||
}
|
||||
|
||||
if (!excludeTypes.contains(VisitType.DOWNLOAD)) {
|
||||
visits = visits + components.core.store.state.downloads.toVisitInfoList(startMillis, endMillis)
|
||||
visits = visits + components.core.store.state.downloads.toVisitInfoList(
|
||||
startMillis,
|
||||
endMillis
|
||||
)
|
||||
}
|
||||
|
||||
callback(Result.success(visits
|
||||
))
|
||||
callback(
|
||||
Result.success(
|
||||
visits
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getVisitsPaginated(
|
||||
offset: Long,
|
||||
count: Long,
|
||||
excludeTypes: List<VisitType>,
|
||||
callback: (Result<List<VisitInfo>>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
var visits = components.core.historyStorage.getVisitsPaginated(
|
||||
offset,
|
||||
count,
|
||||
excludeTypes.map {
|
||||
when (it) {
|
||||
VisitType.LINK -> mozilla.components.concept.storage.VisitType.LINK
|
||||
VisitType.TYPED -> mozilla.components.concept.storage.VisitType.TYPED
|
||||
VisitType.BOOKMARK -> mozilla.components.concept.storage.VisitType.BOOKMARK
|
||||
VisitType.EMBED -> mozilla.components.concept.storage.VisitType.EMBED
|
||||
VisitType.REDIRECT_PERMANENT -> mozilla.components.concept.storage.VisitType.REDIRECT_PERMANENT
|
||||
VisitType.REDIRECT_TEMPORARY -> mozilla.components.concept.storage.VisitType.REDIRECT_TEMPORARY
|
||||
VisitType.DOWNLOAD -> mozilla.components.concept.storage.VisitType.DOWNLOAD
|
||||
VisitType.FRAMED_LINK -> mozilla.components.concept.storage.VisitType.FRAMED_LINK
|
||||
VisitType.RELOAD -> mozilla.components.concept.storage.VisitType.RELOAD
|
||||
}
|
||||
}).map {
|
||||
VisitInfo(
|
||||
url = it.url,
|
||||
title = it.title,
|
||||
visitTime = it.visitTime,
|
||||
visitType = when (it.visitType) {
|
||||
mozilla.components.concept.storage.VisitType.LINK -> VisitType.LINK
|
||||
mozilla.components.concept.storage.VisitType.TYPED -> VisitType.TYPED
|
||||
mozilla.components.concept.storage.VisitType.BOOKMARK -> VisitType.BOOKMARK
|
||||
mozilla.components.concept.storage.VisitType.EMBED -> VisitType.EMBED
|
||||
mozilla.components.concept.storage.VisitType.REDIRECT_PERMANENT -> VisitType.REDIRECT_PERMANENT
|
||||
mozilla.components.concept.storage.VisitType.REDIRECT_TEMPORARY -> VisitType.REDIRECT_TEMPORARY
|
||||
mozilla.components.concept.storage.VisitType.DOWNLOAD -> VisitType.DOWNLOAD
|
||||
mozilla.components.concept.storage.VisitType.FRAMED_LINK -> VisitType.FRAMED_LINK
|
||||
mozilla.components.concept.storage.VisitType.RELOAD -> VisitType.RELOAD
|
||||
},
|
||||
previewImageUrl = it.previewImageUrl,
|
||||
isRemote = it.isRemote
|
||||
)
|
||||
}
|
||||
|
||||
if (!excludeTypes.contains(VisitType.DOWNLOAD)) {
|
||||
callback(Result.failure(Throwable("Downloads not supported yet")))
|
||||
// visits = visits + components.core.store.state.downloads.toVisitInfoList(startMillis, endMillis)
|
||||
}
|
||||
|
||||
callback(
|
||||
Result.success(
|
||||
visits
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -133,15 +133,15 @@ class FlutterEventMiddleware(private val flutterEvents: GeckoStateEvents) : Midd
|
||||
) { _ -> }
|
||||
}
|
||||
}
|
||||
is ReaderAction.UpdateReaderScrollYAction -> {
|
||||
runOnUiThread {
|
||||
flutterEvents.onScrollChange(
|
||||
System.currentTimeMillis(),
|
||||
action.tabId,
|
||||
action.scrollY.toLong()
|
||||
) { _ -> }
|
||||
}
|
||||
}
|
||||
// is ReaderAction.UpdateReaderScrollYAction -> {
|
||||
// runOnUiThread {
|
||||
// flutterEvents.onScrollChange(
|
||||
// System.currentTimeMillis(),
|
||||
// action.tabId,
|
||||
// action.scrollY.toLong()
|
||||
// ) { _ -> }
|
||||
// }
|
||||
// }
|
||||
else -> {
|
||||
//logger.debug("Event fired: " + action.javaClass.name)
|
||||
}
|
||||
|
||||
+23
-17
@@ -4911,23 +4911,6 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val
|
||||
}
|
||||
}
|
||||
}
|
||||
fun onScrollChange(timestampArg: Long, tabIdArg: String, scrollYArg: Long, callback: (Result<Unit>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onScrollChange$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(timestampArg, tabIdArg, scrollYArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else {
|
||||
callback(Result.success(Unit))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
fun onPreferenceChange(timestampArg: Long, valueArg: GeckoPref, callback: (Result<Unit>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
@@ -5492,6 +5475,7 @@ interface GeckoDeleteBrowsingDataController {
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface GeckoHistoryApi {
|
||||
fun getDetailedVisits(startMillis: Long, endMillis: Long, excludeTypes: List<VisitType>, callback: (Result<List<VisitInfo>>) -> Unit)
|
||||
fun getVisitsPaginated(offset: Long, count: Long, excludeTypes: List<VisitType>, callback: (Result<List<VisitInfo>>) -> Unit)
|
||||
fun deleteVisit(url: String, timestamp: Long, callback: (Result<Unit>) -> Unit)
|
||||
fun deleteDownload(id: String, callback: (Result<Unit>) -> Unit)
|
||||
fun deleteVisitsBetween(startMillis: Long, endMillis: Long, callback: (Result<Unit>) -> Unit)
|
||||
@@ -5527,6 +5511,28 @@ interface GeckoHistoryApi {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoHistoryApi.getVisitsPaginated$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val offsetArg = args[0] as Long
|
||||
val countArg = args[1] as Long
|
||||
val excludeTypesArg = args[2] as List<VisitType>
|
||||
api.getVisitsPaginated(offsetArg, countArg, excludeTypesArg) { result: Result<List<VisitInfo>> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoHistoryApi.deleteVisit$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
|
||||
Reference in New Issue
Block a user