From 2968cb12aa9a35a1eeda0e49a5dfcba49529c5ab Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 14 Jul 2023 16:31:57 -0400 Subject: [PATCH] Adds EOSE limits to the Video tab --- .../amethyst/service/NostrVideoDataSource.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt index 6dd343e56..93edde4a7 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt @@ -3,6 +3,7 @@ package com.vitorpamplona.amethyst.service import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.service.model.FileHeaderEvent import com.vitorpamplona.amethyst.service.model.FileStorageHeaderEvent +import com.vitorpamplona.amethyst.service.relays.EOSEAccount import com.vitorpamplona.amethyst.service.relays.FeedType import com.vitorpamplona.amethyst.service.relays.JsonFilter import com.vitorpamplona.amethyst.service.relays.TypedFilter @@ -10,6 +11,8 @@ import com.vitorpamplona.amethyst.service.relays.TypedFilter object NostrVideoDataSource : NostrDataSource("VideoFeed") { lateinit var account: Account + val latestEOSEs = EOSEAccount() + fun createContextualFilter(): TypedFilter? { val follows = account.selectedUsersFollowList(account.defaultStoriesFollowList) @@ -22,7 +25,8 @@ object NostrVideoDataSource : NostrDataSource("VideoFeed") { filter = JsonFilter( authors = followKeys, kinds = listOf(FileHeaderEvent.kind, FileStorageHeaderEvent.kind), - limit = 200 + limit = 200, + since = latestEOSEs.users[account.userProfile()]?.followList?.get(account.defaultStoriesFollowList)?.relayList ) ) } @@ -41,12 +45,15 @@ object NostrVideoDataSource : NostrDataSource("VideoFeed") { listOf(it, it.lowercase(), it.uppercase(), it.capitalize()) }.flatten() ), - limit = 100 + limit = 100, + since = latestEOSEs.users[account.userProfile()]?.followList?.get(account.defaultStoriesFollowList)?.relayList ) ) } - val videoFeedChannel = requestNewChannel() + val videoFeedChannel = requestNewChannel() { time, relayUrl -> + latestEOSEs.addOrUpdate(account.userProfile(), account.defaultStoriesFollowList, relayUrl, time) + } override fun updateChannelFilters() { videoFeedChannel.typedFilters = listOfNotNull(createContextualFilter(), createFollowTagsFilter()).ifEmpty { null }