From 782926fbeae137aa26dddb97ea5a036830bbb5f0 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sun, 25 Feb 2024 18:24:50 -0500 Subject: [PATCH] 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. --- .../service/NostrSingleEventDataSource.kt | 64 +++++++++++++------ 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrSingleEventDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrSingleEventDataSource.kt index 3bfaa538f..6d5f14e21 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrSingleEventDataSource.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrSingleEventDataSource.kt @@ -120,27 +120,50 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") { } return groupByEOSEPresence(eventsToWatch).map { - TypedFilter( - types = COMMON_FEED_TYPES, - filter = - JsonFilter( - kinds = - listOf( - TextNoteEvent.KIND, - ReactionEvent.KIND, - RepostEvent.KIND, - GenericRepostEvent.KIND, - ReportEvent.KIND, - LnZapEvent.KIND, - PollNoteEvent.KIND, - ), - tags = mapOf("e" to it.map { it.idHex }, "q" to it.map { it.idHex }), - since = findMinimumEOSEs(it), - // Max amount of "replies" to download on a specific event. - limit = 1000, - ), + listOf( + TypedFilter( + types = COMMON_FEED_TYPES, + filter = + JsonFilter( + kinds = + listOf( + TextNoteEvent.KIND, + ReactionEvent.KIND, + RepostEvent.KIND, + GenericRepostEvent.KIND, + ReportEvent.KIND, + LnZapEvent.KIND, + PollNoteEvent.KIND, + ), + tags = mapOf("e" to it.map { it.idHex }), + since = findMinimumEOSEs(it), + // Max amount of "replies" to download on a specific event. + limit = 1000, + ), + ), ) + }.flatten() + } + + private fun createQuotesFilter(): List? { + 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? { @@ -205,9 +228,10 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") { val missing = createLoadEventsIfNotLoadedFilter() val addresses = createAddressFilter() val addressReactions = createReactionsToWatchInAddressFilter() + val quotes = createQuotesFilter() singleEventChannel.typedFilters = - listOfNotNull(missing, addresses, reactions, addressReactions).flatten().ifEmpty { null } + listOfNotNull(missing, addresses, reactions, addressReactions, quotes).flatten().ifEmpty { null } } fun add(eventId: Note) {