Separates the q filter from the e filter to avoid and moves q to the last position since it can be cut off and won't affect the app.

This commit is contained in:
Vitor Pamplona
2024-02-25 18:24:50 -05:00
parent 21d141c5c2
commit 782926fbea
@@ -120,6 +120,7 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
} }
return groupByEOSEPresence(eventsToWatch).map { return groupByEOSEPresence(eventsToWatch).map {
listOf(
TypedFilter( TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = filter =
@@ -134,13 +135,35 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
LnZapEvent.KIND, LnZapEvent.KIND,
PollNoteEvent.KIND, PollNoteEvent.KIND,
), ),
tags = mapOf("e" to it.map { it.idHex }, "q" to it.map { it.idHex }), tags = mapOf("e" to it.map { it.idHex }),
since = findMinimumEOSEs(it), since = findMinimumEOSEs(it),
// Max amount of "replies" to download on a specific event. // Max amount of "replies" to download on a specific event.
limit = 1000, limit = 1000,
), ),
),
) )
}.flatten()
} }
private fun createQuotesFilter(): List<TypedFilter>? {
if (eventsToWatch.isEmpty()) {
return null
}
return groupByEOSEPresence(eventsToWatch).map {
listOf(
TypedFilter(
types = COMMON_FEED_TYPES,
filter =
JsonFilter(
tags = mapOf("q" to it.map { it.idHex }),
since = findMinimumEOSEs(it),
// Max amount of "replies" to download on a specific event.
limit = 1000,
),
),
)
}.flatten()
} }
fun createLoadEventsIfNotLoadedFilter(): List<TypedFilter>? { fun createLoadEventsIfNotLoadedFilter(): List<TypedFilter>? {
@@ -205,9 +228,10 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
val missing = createLoadEventsIfNotLoadedFilter() val missing = createLoadEventsIfNotLoadedFilter()
val addresses = createAddressFilter() val addresses = createAddressFilter()
val addressReactions = createReactionsToWatchInAddressFilter() val addressReactions = createReactionsToWatchInAddressFilter()
val quotes = createQuotesFilter()
singleEventChannel.typedFilters = singleEventChannel.typedFilters =
listOfNotNull(missing, addresses, reactions, addressReactions).flatten().ifEmpty { null } listOfNotNull(missing, addresses, reactions, addressReactions, quotes).flatten().ifEmpty { null }
} }
fun add(eventId: Note) { fun add(eventId: Note) {