Reduces the amount of Reports downloaded when observing single users.

This commit is contained in:
Vitor Pamplona 2023-02-18 19:06:05 -05:00
parent b7c72a282f
commit ccd6beee8e

View File

@ -34,7 +34,8 @@ object NostrSingleUserDataSource: NostrDataSource("SingleUserFeed") {
types = FeedType.values().toSet(),
filter = JsonFilter(
kinds = listOf(ReportEvent.kind),
tags = mapOf("p" to listOf(it))
tags = mapOf("p" to listOf(it)),
since = LocalCache.users[it]?.latestReportTime
)
)
}
@ -46,8 +47,11 @@ object NostrSingleUserDataSource: NostrDataSource("SingleUserFeed") {
invalidateFilters()
}
val userChannelOnce = requestNewChannel()
override fun updateChannelFilters() {
userChannel.typedFilters = listOfNotNull(createUserFilter(), createUserReportFilter()).flatten()
userChannel.typedFilters = listOfNotNull(createUserFilter()).flatten().ifEmpty { null }
userChannelOnce.typedFilters = listOfNotNull(createUserReportFilter()).flatten().ifEmpty { null }
}
fun add(userId: String) {