diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt index 09a1c1c1d1..d481d152b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt @@ -221,15 +221,6 @@ import com.vitorpamplona.quartz.nip18Reposts.BaseRepostEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip18Reposts.quotes.taggedQuoteIds -import com.vitorpamplona.quartz.nip19Bech32.entities.Entity -import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress -import com.vitorpamplona.quartz.nip19Bech32.entities.NEmbed -import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent -import com.vitorpamplona.quartz.nip19Bech32.entities.NNote -import com.vitorpamplona.quartz.nip19Bech32.entities.NProfile -import com.vitorpamplona.quartz.nip19Bech32.entities.NPub -import com.vitorpamplona.quartz.nip19Bech32.entities.NRelay -import com.vitorpamplona.quartz.nip19Bech32.entities.NSec import com.vitorpamplona.quartz.nip19Bech32.isATag import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent @@ -743,7 +734,9 @@ object LocalCache : ILocalCache, ICacheProvider, Dao { fun getRelayGroupChannelIfExists(key: GroupId): RelayGroupChannel? = relayGroupChannels.get(key) /** Every relay group we know of that is hosted on [relay] (its channel directory). */ - fun getRelayGroupChannelsOnRelay(relay: NormalizedRelayUrl): List = relayGroupChannels.filter { key, _ -> key.relayUrl == relay } + override fun getRelayGroupChannelsOnRelay(relay: NormalizedRelayUrl): List = relayGroupChannels.filter { key, _ -> key.relayUrl == relay } + + override fun allRelayGroupChannels(): List = relayGroupChannels.values().toList() /** * The [RelayGroupChannel] a group-scoped content [note] belongs to, resolved the same way @@ -3300,53 +3293,8 @@ object LocalCache : ILocalCache, ICacheProvider, Dao { wasVerified: Boolean, ): Boolean = !event.isDeleted() && consumeBaseReplaceable(event, relay, wasVerified) - fun consume(nip19: Entity) { - when (nip19) { - is NSec -> { - getOrCreateUser(nip19.toPubKeyHex()) - } - - is NPub -> { - getOrCreateUser(nip19.hex) - } - - is NProfile -> { - nip19.relay.forEach { relayHint -> - relayHints.addKey(nip19.hex, relayHint) - } - getOrCreateUser(nip19.hex) - } - - is NNote -> { - getOrCreateNote(nip19.hex) - } - - is NEvent -> { - nip19.relay.forEach { relayHint -> - relayHints.addEvent(nip19.hex, relayHint) - } - val note = getOrCreateNote(nip19.hex) - if (note.author == null) { - nip19.author?.let { note.author = checkGetOrCreateUser(it) } - } - } - - is NEmbed -> { - justConsume(nip19.event, null, false) - } - - is NRelay -> {} - - is NAddress -> { - val aTag = nip19.aTag() - nip19.relay.forEach { relayHint -> - relayHints.addAddress(aTag, relayHint) - } - getOrCreateAddressableNote(nip19.address()) - } - - else -> { } - } + override fun consumeEmbedded(event: Event) { + justConsume(event, null, false) } override fun justConsumeMyOwnEvent(event: Event) = justConsumeAndUpdateIndexes(event, null, true) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/RelaySubscriptionsCoordinator.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/RelaySubscriptionsCoordinator.kt index 82cd348f9d..899c81b4b0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/RelaySubscriptionsCoordinator.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/RelaySubscriptionsCoordinator.kt @@ -20,24 +20,59 @@ */ package com.vitorpamplona.amethyst.service.relayClient.reqCommand +import com.vitorpamplona.amethyst.commons.relayClient.articles.ArticlesFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.assemblers.CashuMintDirectoryFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.badges.BadgesFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.calendars.CalendarsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.channel.ChannelFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.chess.ChessFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.communities.CommunityFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.communities.list.CommunitiesListFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.discover.DiscoveryFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.emojipacks.BrowseEmojiSetsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.event.EventFinderFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.followPacks.FollowPacksFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.geohash.GeoHashFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.gitRepo.RepositoryFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.GitRepositoriesFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.highlights.HighlightsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.livestreams.LiveStreamsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.longs.LongsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.music.MusicPlaylistsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.music.MusicTracksFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.napplets.NappletsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.nests.NestsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.nip47WalletConnect.NWCPaymentFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.nsites.NsitesFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.pictures.PicturesFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.MyPodcastFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.OnePodcastFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PodcastEpisodesFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PodcastsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.polls.PollsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.polls.results.PollResponsesFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.products.ProductsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.profile.UserProfileFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.publicChats.PublicChatsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.relay.RelayFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.relays.RelayInfoNip66FilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.shorts.ShortsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.SoftwareAppsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.url.UrlFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.user.UserFinderFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.video.VideoFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.wallet.OnchainZapsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.workouts.WorkoutsFilterAssembler import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.service.relayClient.reqCommand.account.AccountFilterAssembler import com.vitorpamplona.amethyst.service.relayClient.reqCommand.account.AccountForegroundFilterAssembler import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderFilterAssemblyGroup import com.vitorpamplona.amethyst.service.relayClient.searchCommand.SearchFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.apps.recommendations.datasource.ProfileAppRecommendationsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.articles.datasource.ArticlesFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.badges.datasource.BadgesFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.badges.profile.datasource.ProfileBadgesFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.CalendarsFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.datasource.ChatroomFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.concord.datasource.ConcordChannelFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.concord.datasource.ConcordChannelHistoryFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.ChannelFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.BuzzDmJoinedChatTailFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RelayGroupCardWarmupFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RelayGroupJoinedChatTailFilterAssembler @@ -49,48 +84,13 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayG import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RelayGroupsDiscoveryFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RelayGroupsOnRelayFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.datasource.ChatroomListFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chess.datasource.ChessFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource.CommunityFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.list.datasource.CommunitiesListFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource.DiscoveryFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.BrowseEmojiSetsFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.datasource.FollowPackFeedFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.list.datasource.FollowPacksFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.datasource.GeoHashFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.datasource.RepositoryFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.GitRepositoriesFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.hashtag.datasource.HashtagFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.HighlightsFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.HomeFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.livestreams.datasource.LiveStreamsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.LongsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.MusicPlaylistsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.MusicTracksFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.ConnectedAppsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.NappletsFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.NestRoomFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.NestRoomLivenessAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.NestsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.NsitesFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.PicturesFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.MyPodcastFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.OnePodcastFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.PodcastEpisodesFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.PodcastsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.PollsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.results.datasources.PollResponsesFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.products.datasource.ProductsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource.UserProfileFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.publicChats.datasource.PublicChatsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.relay.datasource.RelayFeedFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.datasource.RelayInfoNip66FilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.ShortsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.SoftwareAppsFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.threadview.datasources.ThreadFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.url.datasource.UrlFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.VideoFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.wallet.datasource.OnchainZapsFilterAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.WorkoutsFilterAssembler import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.accessories.RelayOfflineTracker import com.vitorpamplona.quartz.nip01Core.relay.client.auth.IAuthStatus @@ -154,10 +154,10 @@ class RelaySubscriptionsCoordinator( val concordChannelHistory = ConcordChannelHistoryFilterAssembler(client) val chatroom = ChatroomFilterAssembler(client) - val community = CommunityFilterAssembler(client) - val gitRepository = RepositoryFilterAssembler(client) + val community = CommunityFilterAssembler(cache, client) + val gitRepository = RepositoryFilterAssembler(cache, client) val thread = ThreadFilterAssembler(client) - val profile = UserProfileFilterAssembler(client) + val profile = UserProfileFilterAssembler(cache, client) val hashtags = HashtagFilterAssembler(client) val geohashes = GeoHashFilterAssembler(client) val urls = UrlFilterAssembler(client) @@ -170,7 +170,7 @@ class RelaySubscriptionsCoordinator( val polls = PollsFilterAssembler(client) // Votes for the poll whose results screen is open. - val pollResponses = PollResponsesFilterAssembler(client) + val pollResponses = PollResponsesFilterAssembler(cache, client) val pictures = PicturesFilterAssembler(client) val workouts = WorkoutsFilterAssembler(client) val gitRepositories = GitRepositoriesFilterAssembler(client) @@ -189,8 +189,8 @@ class RelaySubscriptionsCoordinator( val musicPlaylists = MusicPlaylistsFilterAssembler(client) val podcastEpisodes = PodcastEpisodesFilterAssembler(client) val podcasts = PodcastsFilterAssembler(client) - val onePodcast = OnePodcastFilterAssembler(client) - val myPodcast = MyPodcastFilterAssembler(client) + val onePodcast = OnePodcastFilterAssembler(cache, client) + val myPodcast = MyPodcastFilterAssembler(cache, client) val softwareApps = SoftwareAppsFilterAssembler(client) val napplets = NappletsFilterAssembler(client) val connectedApps = ConnectedAppsFilterAssembler(client) @@ -205,7 +205,7 @@ class RelaySubscriptionsCoordinator( val nwc = NWCPaymentFilterAssembler(client) // active when the wallet's on-chain transactions screen is on top. - val onchainZaps = OnchainZapsFilterAssembler(client) + val onchainZaps = OnchainZapsFilterAssembler(cache, client) // active while the user is browsing the NIP-87 mint picker. Subscribes to // kind:38172 cashu mint announcements + kind:38000 cashu-scoped diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/SearchFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/SearchFilterAssembler.kt index 4c24220c82..084706d591 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/SearchFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/SearchFilterAssembler.kt @@ -21,32 +21,19 @@ package com.vitorpamplona.amethyst.service.relayClient.searchCommand import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.MutableComposeSubscriptionManager -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.MutableQueryState -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.model.LocalCache -import com.vitorpamplona.amethyst.service.relayClient.searchCommand.subassemblies.SearchPostWatcherSubAssembler -import com.vitorpamplona.amethyst.service.relayClient.searchCommand.subassemblies.SearchUserWatcherSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.search.SearchPostWatcherSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.search.SearchQueryState +import com.vitorpamplona.amethyst.commons.relayClient.search.SearchUserWatcherSubAssembler import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableStateFlow - -@Stable -class SearchQueryState( - val searchQuery: MutableStateFlow, - override val account: Account, -) : MutableQueryState, - AccountScopedQuery { - override fun flow(): Flow = searchQuery -} @Stable class SearchFilterAssembler( client: INostrClient, scope: CoroutineScope, - val cache: LocalCache, + val cache: ICacheProvider, ) : MutableComposeSubscriptionManager(scope) { val group = listOf( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt index 841a379f8e..94534ff21a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt @@ -25,9 +25,9 @@ import androidx.compose.runtime.Stable import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.input.TextFieldValue import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.relayClient.search.SearchQueryState import com.vitorpamplona.amethyst.logTime import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.service.relayClient.searchCommand.SearchQueryState import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.normalizeRelayUrlOrNull @@ -92,7 +92,14 @@ class UserSuggestionState( ) { val invalidations = MutableStateFlow(0) val currentWord = MutableStateFlow("") - val searchDataSourceState = SearchQueryState(MutableStateFlow(""), account) + val searchDataSourceState = + SearchQueryState( + searchQuery = MutableStateFlow(""), + account = account, + searchRelays = account.searchRelayList.flow, + indexerRelays = account.indexerRelayList.flow, + followPlusAllMineWithSearchRelays = account.followPlusAllMineWithSearch.flow, + ) @OptIn(FlowPreview::class) val searchTerm = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt index e16df43e2f..2aa95b4c21 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt @@ -67,6 +67,7 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.nip30CustomEmojis.ui.ShowEmojiSuggestionList +import com.vitorpamplona.amethyst.commons.relayClient.communities.CommunityFilterAssemblerSubscription import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.geo_post_change_place import com.vitorpamplona.amethyst.commons.resources.geo_post_posting_to @@ -115,7 +116,6 @@ import com.vitorpamplona.amethyst.ui.note.creators.zapsplits.ForwardZapTo import com.vitorpamplona.amethyst.ui.note.creators.zapsplits.ForwardZapToButton import com.vitorpamplona.amethyst.ui.note.types.ReplyRenderType import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource.CommunityFilterAssemblerSubscription import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.Size30Modifier diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/TopNavFeedQueryStates.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/TopNavFeedQueryStates.kt new file mode 100644 index 0000000000..9a39283b4e --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/TopNavFeedQueryStates.kt @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.ui.screen.loggedIn + +import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState +import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState +import kotlinx.coroutines.flow.StateFlow + +/** + * Builds the key for a top-nav-driven feed subscription out of this view model's account and feed + * states: the selected list, its per-relay resolution, and the feed(s) whose floor bounds `since`. + */ +fun AccountViewModel.topNavFeedQueryState( + listName: StateFlow, + followsPerRelay: StateFlow, + vararg feeds: FeedContentState, +) = TopNavFeedQueryState(account, listName, followsPerRelay, viewModelScope, feeds.toList()) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesFilterAssemblerSubscription.kt index 8be1a112b8..58eedf1702 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.articles.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.articles.ArticlesFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun ArticlesFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun ArticlesFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - ArticlesQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultArticlesFollowList, + account.liveArticlesFollowListsPerRelay, + accountViewModel.feedStates.articlesFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesSubAssembler.kt deleted file mode 100644 index 306bf559d4..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesSubAssembler.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.articles.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.makeLongFormFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class ArticlesSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: ArticlesQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeLongFormFilter(feedSettings, since, key.feedStates.articlesFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: ArticlesQueryState) = key.account.userProfile() - - override fun list(key: ArticlesQueryState) = key.listName() - - fun ArticlesQueryState.listNameFlow() = account.settings.defaultArticlesFollowList - - fun ArticlesQueryState.listName() = listNameFlow().value - - fun ArticlesQueryState.followsPerRelayFlow() = account.liveArticlesFollowListsPerRelay - - fun ArticlesQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: ArticlesQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.articlesFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesFilterAssemblerSubscription.kt index 5ce4d48f7a..d973e12507 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.badges.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.badges.BadgesFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun BadgesFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun BadgesFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - BadgesQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultBadgesFollowList, + account.liveBadgesFollowListsPerRelay, + accountViewModel.feedStates.badgesFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesSubAssembler.kt deleted file mode 100644 index 1409f66908..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesSubAssembler.kt +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.badges.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class BadgesSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: BadgesQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow now resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me]. - val defaultSince = key.feedStates.badgesFeed.lastNoteCreatedAtIfFilled() - - return makeBadgesFilter(key.followsPerRelay(), since, defaultSince) - } - - override fun user(key: BadgesQueryState) = key.account.userProfile() - - override fun list(key: BadgesQueryState) = key.listName() - - fun BadgesQueryState.listNameFlow() = account.settings.defaultBadgesFollowList - - fun BadgesQueryState.listName() = listNameFlow().value - - fun BadgesQueryState.followsPerRelayFlow() = account.liveBadgesFollowListsPerRelay - - fun BadgesQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: BadgesQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.badgesFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmDiscovery.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmDiscovery.kt index fa94aaa886..80b0da3237 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmDiscovery.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmDiscovery.kt @@ -25,6 +25,7 @@ import androidx.compose.runtime.LaunchedEffect import com.vitorpamplona.amethyst.commons.model.buzz.BuzzChannelInvites import com.vitorpamplona.amethyst.commons.model.buzz.BuzzDmChannels import com.vitorpamplona.amethyst.commons.model.buzz.ChannelClassification +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_METADATA_KINDS import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.buzz.buzzChannelTypes @@ -32,7 +33,6 @@ import com.vitorpamplona.amethyst.model.buzz.classifyBuzzChannel import com.vitorpamplona.amethyst.model.buzz.membershipNoticeFilter import com.vitorpamplona.amethyst.model.buzz.membershipNotices import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RELAY_GROUP_METADATA_KINDS import com.vitorpamplona.quartz.nip01Core.relay.client.accessories.fetchAllWithHooks import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmListViewModel.kt index 65395c3f9f..dd2284163e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzDmListViewModel.kt @@ -28,12 +28,12 @@ import com.vitorpamplona.amethyst.commons.model.buzz.BuzzDmChannels import com.vitorpamplona.amethyst.commons.model.buzz.BuzzDmRegistry import com.vitorpamplona.amethyst.commons.model.buzz.BuzzRelayDialect import com.vitorpamplona.amethyst.commons.model.cache.filter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_METADATA_KINDS import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthDecision import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.buzz.membershipNoticeFilter import com.vitorpamplona.amethyst.model.buzz.membershipNotices -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RELAY_GROUP_METADATA_KINDS import com.vitorpamplona.quartz.buzz.dvDmVisibility.DmVisibilityEvent import com.vitorpamplona.quartz.buzz.notifications.MemberAddedNotificationEvent import com.vitorpamplona.quartz.buzz.stream.StreamMessageV2Event diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzRelayImportViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzRelayImportViewModel.kt index 2b4cf9a15f..2498256719 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzRelayImportViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/BuzzRelayImportViewModel.kt @@ -23,10 +23,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.buzz import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupDeletions +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_METADATA_KINDS import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthDecision import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.LocalCache -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RELAY_GROUP_METADATA_KINDS import com.vitorpamplona.quartz.buzz.notifications.MemberAddedNotificationEvent import com.vitorpamplona.quartz.buzz.stream.SystemMessageEvent import com.vitorpamplona.quartz.buzz.workspace.isBuzzDm diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsFilterAssemblerSubscription.kt index 5f77520fb1..7346b33ca6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.calendars.CalendarsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun CalendarsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun CalendarsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - CalendarsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultCalendarsFollowList, + account.liveCalendarsFollowListsPerRelay, + accountViewModel.feedStates.calendarAppointmentsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsSubAssembler.kt deleted file mode 100644 index 6589e67072..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsSubAssembler.kt +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class CalendarsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: CalendarsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeCalendarsFilter(feedSettings, since, key.feedStates.calendarAppointmentsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: CalendarsQueryState) = key.account.userProfile() - - override fun list(key: CalendarsQueryState) = key.listName() - - fun CalendarsQueryState.listNameFlow() = account.settings.defaultCalendarsFollowList - - fun CalendarsQueryState.listName() = listNameFlow().value - - fun CalendarsQueryState.followsPerRelayFlow() = account.liveCalendarsFollowListsPerRelay - - fun CalendarsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: CalendarsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - // Calendar events are addressables stored in LocalCache's WeakReference - // map: while the user is viewing list B the strong refs from list A's UI - // are gone and the GC may reclaim those notes. If the EOSE cursor for the - // list the user is switching back to still says "you have everything up - // to T", the relay won't re-send the now-evicted events. Clearing the - // cursor here forces a fresh fetch so the feed comes back whole. - clearEoseFor(key) - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.calendarAppointmentsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/ChannelFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/ChannelFilterAssemblerSubscription.kt index 5d35c1a32a..5c44846340 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/ChannelFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/ChannelFilterAssemblerSubscription.kt @@ -28,6 +28,8 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.model.Channel import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.amethyst.commons.model.nip53LiveActivities.LiveActivitiesChannel +import com.vitorpamplona.amethyst.commons.relayClient.channel.ChannelFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.channel.ChannelQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzDmJoinedChatTailFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzDmJoinedChatTailFilterAssembler.kt index a79547ba32..a91cf06711 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzDmJoinedChatTailFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzDmJoinedChatTailFilterAssembler.kt @@ -25,6 +25,9 @@ import com.vitorpamplona.amethyst.commons.model.buzz.BuzzDmRegistry import com.vitorpamplona.amethyst.commons.model.privateChats.DmHistoryTuning import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery import com.vitorpamplona.amethyst.commons.relayClient.account.nip01Notifications.filterGroupNotificationsToPubkey +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupAuxFilter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupJoinedChatTailFilter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupPreviewFilter import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.paging.WindowLoadTracker diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupCardWarmupFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupCardWarmupFilterAssembler.kt index bb8db4b7cd..7f6fc59e17 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupCardWarmupFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupCardWarmupFilterAssembler.kt @@ -22,13 +22,15 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relay import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.channel.filterRelayGroupState +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_CARD_WARMUP_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.isRelayGroupJoined import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies.filterRelayGroupState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip29RelayGroups.GroupId diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupChatSubscriptions.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupChatSubscriptions.kt index 4b1f5d3b22..f137c02d54 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupChatSubscriptions.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupChatSubscriptions.kt @@ -29,6 +29,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.model.buzz.BuzzDmChannels import com.vitorpamplona.amethyst.commons.model.buzz.BuzzDmRegistry import com.vitorpamplona.amethyst.commons.model.chats.ChatFeedType +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupJoinedChatTailFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.KeyDataSourceSubscription import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedChatTailFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedChatTailFilterAssembler.kt index cd8aa4ec11..45720e264c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedChatTailFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedChatTailFilterAssembler.kt @@ -25,6 +25,10 @@ import com.vitorpamplona.amethyst.commons.model.chats.ChatFeedType import com.vitorpamplona.amethyst.commons.model.privateChats.DmHistoryTuning import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery import com.vitorpamplona.amethyst.commons.relayClient.account.nip01Notifications.filterGroupNotificationsToPubkey +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupAuxFilter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupJoinedChatTailFilter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupLiveStateFilter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupPreviewFilter import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.paging.WindowLoadTracker diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedStateFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedStateFilterAssembler.kt index 54b55349fc..3d4d4f2960 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedStateFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupJoinedStateFilterAssembler.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relay import com.vitorpamplona.amethyst.commons.model.chats.ChatFeedType import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupStateFilters import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatHistoryFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatHistoryFilterAssembler.kt index b3c5dc293d..f2fa2c462c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatHistoryFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatHistoryFilterAssembler.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupHistoryFilters import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.paging.BackwardRelayPager diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatTailFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatTailFilterAssembler.kt index e914dc7d35..e1b3fb92d9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatTailFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenChatTailFilterAssembler.kt @@ -22,6 +22,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relay import com.vitorpamplona.amethyst.commons.model.privateChats.DmHistoryTuning import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupAuxFilter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupOpenChatTailFilter import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.paging.WindowLoadTracker diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsFilterAssembler.kt index 9fcf32684a..72de0c6434 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsFilterAssembler.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupThreadsFilter import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsHistoryFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsHistoryFilterAssembler.kt index 5b4abfd2c6..c8173a363f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsHistoryFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupOpenThreadsHistoryFilterAssembler.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupThreadsHistoryFilters import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.paging.BackwardRelayPager diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoveryFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoveryFilter.kt index f5b54a4a70..96a00d8091 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoveryFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoveryFilter.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet @@ -30,32 +31,33 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.Aut import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.relay.RelayTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByRelay +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByRelay -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun filterRelayGroupsDiscovery( + cache: ICacheProvider, feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, defaultSince: Long? = null, ): List = when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterRelayGroupsByAllCommunities(feedSettings, since, defaultSince) - is AllFollowsTopNavPerRelayFilterSet -> filterRelayGroupsByFollows(feedSettings, since, defaultSince) - is AuthorsTopNavPerRelayFilterSet -> filterRelayGroupsByAuthors(feedSettings, since, defaultSince) + is AllFollowsTopNavPerRelayFilterSet -> filterRelayGroupsByFollows(cache, feedSettings, since, defaultSince) + is AuthorsTopNavPerRelayFilterSet -> filterRelayGroupsByAuthors(cache, feedSettings, since, defaultSince) is GlobalTopNavPerRelayFilterSet -> filterRelayGroupsGlobal(feedSettings, since, defaultSince) is HashtagTopNavPerRelayFilterSet -> filterRelayGroupsByHashtag(feedSettings, since, defaultSince) is LocationTopNavPerRelayFilterSet -> filterRelayGroupsByGeohashes(feedSettings, since, defaultSince) - is MutedAuthorsTopNavPerRelayFilterSet -> filterRelayGroupsByMutedAuthors(feedSettings, since, defaultSince) + is MutedAuthorsTopNavPerRelayFilterSet -> filterRelayGroupsByMutedAuthors(cache, feedSettings, since, defaultSince) is RelayTopNavPerRelayFilterSet -> filterRelayGroupsByRelay(feedSettings, since, defaultSince) is SingleCommunityTopNavPerRelayFilterSet -> filterRelayGroupsByCommunity(feedSettings, since, defaultSince) else -> emptyList() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt index 9cf3690737..4e9e31a924 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt @@ -24,12 +24,12 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.filterRelayGroupsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.relayGroupChannelsByRelay import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.amethyst.model.LocalCache -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.filterRelayGroupsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies.relayGroupChannelsByRelay import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @@ -56,7 +56,7 @@ class RelayGroupsDiscoverySubAssembler( val feedSettings = key.followsPerRelay() val defaultSince = key.feedStates.relayGroupsDiscoveryFeed.lastNoteCreatedAtIfFilled() - val base = filterRelayGroupsDiscovery(feedSettings, since, defaultSince) + val base = filterRelayGroupsDiscovery(LocalCache, feedSettings, since, defaultSince) // The follow-list filter sets resolve their relays via the outbox model (a follow's own // publish relays), but a NIP-29 roster (39001/39002) lives ONLY on the group's host relay. @@ -78,7 +78,7 @@ class RelayGroupsDiscoverySubAssembler( val hostRelays = key.groupHostRelays() - alreadyQueried if (hostRelays.isEmpty()) return base - val channelsByRelay = relayGroupChannelsByRelay() + val channelsByRelay = relayGroupChannelsByRelay(LocalCache) val extra = hostRelays.flatMap { relay -> filterRelayGroupsByAuthors( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsOnRelayFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsOnRelayFilterAssembler.kt index 55008995d3..0059a589b8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsOnRelayFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsOnRelayFilterAssembler.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupDirectoryFilter import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessSubscription.kt index 97e17fb049..d8d788c180 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessSubscription.kt @@ -25,6 +25,7 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.commons.relayClient.chess.ChessQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.chess.ChessViewModelNew diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt index 981718c5df..3d0f4e0a67 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/CommunityScreen.kt @@ -44,6 +44,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.commons.model.AddressableNote +import com.vitorpamplona.amethyst.commons.relayClient.communities.CommunityFilterAssemblerSubscription import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.feed import com.vitorpamplona.amethyst.commons.resources.mod_queue @@ -64,7 +65,6 @@ import com.vitorpamplona.amethyst.ui.screen.RefresheableFeedView import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.dal.CommunityFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.dal.CommunityModerationFeedViewModel -import com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource.CommunityFilterAssemblerSubscription import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.Size35dp import com.vitorpamplona.amethyst.ui.theme.TabRowHeight diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListFilterAssemblerSubscription.kt index c04be6c0c3..3fe66d5843 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.list.datasourc import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.communities.list.CommunitiesListFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun CommunitiesListFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun CommunitiesListFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - CommunitiesListQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultCommunitiesFollowList, + account.liveCommunitiesFollowListsPerRelay, + accountViewModel.feedStates.communitiesList, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListSubAssembler.kt deleted file mode 100644 index f76ffb78b0..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListSubAssembler.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.list.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.makeCommunitiesFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class CommunitiesListSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: CommunitiesListQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow now resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me]. - val defaultSince = key.feedStates.communitiesList.lastNoteCreatedAtIfFilled() - - return makeCommunitiesFilter(key.followsPerRelay(), since, defaultSince) - } - - override fun user(key: CommunitiesListQueryState) = key.account.userProfile() - - override fun list(key: CommunitiesListQueryState) = key.listName() - - fun CommunitiesListQueryState.listNameFlow() = account.settings.defaultCommunitiesFollowList - - fun CommunitiesListQueryState.listName() = listNameFlow().value - - fun CommunitiesListQueryState.followsPerRelayFlow() = account.liveCommunitiesFollowListsPerRelay - - fun CommunitiesListQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: CommunitiesListQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.communitiesList.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt index 54a518e708..be668aaa61 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt @@ -23,6 +23,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.discover.DiscoveryFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.discover.DiscoveryQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -43,7 +45,21 @@ fun DiscoveryFilterAssemblerSubscription( // even if they are tracking the same tag. val state = remember(accountViewModel.account) { - DiscoveryQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + val feeds = accountViewModel.feedStates + DiscoveryQueryState( + account = account, + listName = account.settings.defaultDiscoveryFollowList, + followsPerRelay = account.liveDiscoveryFollowListsPerRelay, + scope = accountViewModel.viewModelScope, + reads = feeds.discoverReads, + marketplace = feeds.discoverMarketplace, + dvms = feeds.discoverDVMs, + followSets = feeds.discoverFollowSets, + live = feeds.discoverLive, + publicChats = feeds.discoverPublicChats, + communities = feeds.discoverCommunities, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt deleted file mode 100644 index 10ffde7825..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.makeFollowSetsFilter -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.makeLiveActivitiesFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class DiscoveryFollowsSetsAndLiveStreamsSubAssembler2( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: DiscoveryQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeFollowSetsFilter(feedSettings, since, key.feedStates.discoverFollowSets.lastNoteCreatedAtIfFilled()) + - makeLiveActivitiesFilter(feedSettings, since, key.feedStates.discoverLive.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: DiscoveryQueryState) = key.account.userProfile() - - override fun list(key: DiscoveryQueryState) = key.listName() - - fun DiscoveryQueryState.listNameFlow() = account.settings.defaultDiscoveryFollowList - - fun DiscoveryQueryState.listName() = listNameFlow().value - - fun DiscoveryQueryState.followsPerRelayFlow() = account.liveDiscoveryFollowListsPerRelay - - fun DiscoveryQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: DiscoveryQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(1000).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - combine( - key.feedStates.discoverFollowSets.lastNoteCreatedAtWhenFullyLoaded, - key.feedStates.discoverLive.lastNoteCreatedAtWhenFullyLoaded, - ) { - Any() - }.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt deleted file mode 100644 index 46bb47f871..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.makeLongFormFilter -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.makeContentDVMsFilter -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.makeClassifiedsFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class DiscoveryLongFormClassifiedsAndDVMSubAssembler1( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: DiscoveryQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeLongFormFilter(feedSettings, since, key.feedStates.discoverReads.lastNoteCreatedAtIfFilled()) + - makeClassifiedsFilter(feedSettings, since, key.feedStates.discoverMarketplace.lastNoteCreatedAtIfFilled()) + - makeContentDVMsFilter(feedSettings, since, key.feedStates.discoverDVMs.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: DiscoveryQueryState) = key.account.userProfile() - - override fun list(key: DiscoveryQueryState) = key.listName() - - fun DiscoveryQueryState.listNameFlow() = account.settings.defaultDiscoveryFollowList - - fun DiscoveryQueryState.listName() = listNameFlow().value - - fun DiscoveryQueryState.followsPerRelayFlow() = account.liveDiscoveryFollowListsPerRelay - - fun DiscoveryQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: DiscoveryQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - combine( - key.feedStates.discoverReads.lastNoteCreatedAtWhenFullyLoaded, - key.feedStates.discoverDVMs.lastNoteCreatedAtWhenFullyLoaded, - key.feedStates.discoverMarketplace.lastNoteCreatedAtWhenFullyLoaded, - ) { - Any() - }.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt deleted file mode 100644 index 49a5693833..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.makePublicChatsFilter -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.makeCommunitiesFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class DiscoveryPublicChatsAndCommunitiesSubAssembler3( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: DiscoveryQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - return makePublicChatsFilter(feedSettings, since, key.feedStates.discoverPublicChats.lastNoteCreatedAtIfFilled()) + - makeCommunitiesFilter(feedSettings, since, key.feedStates.discoverCommunities.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: DiscoveryQueryState) = key.account.userProfile() - - override fun list(key: DiscoveryQueryState) = key.listName() - - fun DiscoveryQueryState.listNameFlow() = account.settings.defaultDiscoveryFollowList - - fun DiscoveryQueryState.listName() = listNameFlow().value - - fun DiscoveryQueryState.followsPerRelayFlow() = account.liveDiscoveryFollowListsPerRelay - - fun DiscoveryQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: DiscoveryQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - combine( - key.feedStates.discoverPublicChats.lastNoteCreatedAtWhenFullyLoaded, - key.feedStates.discoverCommunities.lastNoteCreatedAtWhenFullyLoaded, - ) { - Any() - }.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsFilterAssemblerSubscription.kt index 9fb3e7d309..1ed6bba621 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasour import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.emojipacks.BrowseEmojiSetsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun BrowseEmojiSetsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun BrowseEmojiSetsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - BrowseEmojiSetsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultBrowseEmojiSetsFollowList, + account.liveBrowseEmojiSetsFollowListsPerRelay, + accountViewModel.feedStates.browseEmojiSetsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsSubAssembler.kt deleted file mode 100644 index a6bd9093c9..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsSubAssembler.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class BrowseEmojiSetsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: BrowseEmojiSetsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - val defaultSince = key.feedStates.browseEmojiSetsFeed.lastNoteCreatedAtIfFilled() - - return makeBrowseEmojiSetsFilter(feedSettings, since, defaultSince) - } - - override fun user(key: BrowseEmojiSetsQueryState) = key.account.userProfile() - - override fun list(key: BrowseEmojiSetsQueryState) = key.listName() - - fun BrowseEmojiSetsQueryState.listNameFlow() = account.settings.defaultBrowseEmojiSetsFollowList - - fun BrowseEmojiSetsQueryState.listName() = listNameFlow().value - - fun BrowseEmojiSetsQueryState.followsPerRelayFlow() = account.liveBrowseEmojiSetsFollowListsPerRelay - - fun BrowseEmojiSetsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: BrowseEmojiSetsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.feedStates.browseEmojiSetsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksFilterAssemblerSubscription.kt index 8b8256ff1e..04be70b8f8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.list.datasourc import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.followPacks.FollowPacksFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun FollowPacksFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun FollowPacksFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - FollowPacksQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultFollowPacksFollowList, + account.liveFollowPacksFollowListsPerRelay, + accountViewModel.feedStates.followPacksFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksSubAssembler.kt deleted file mode 100644 index 841c0cb3c8..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksSubAssembler.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.list.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.makeFollowSetsFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class FollowPacksSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: FollowPacksQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeFollowSetsFilter(feedSettings, since, key.feedStates.followPacksFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: FollowPacksQueryState) = key.account.userProfile() - - override fun list(key: FollowPacksQueryState) = key.listName() - - fun FollowPacksQueryState.listNameFlow() = account.settings.defaultFollowPacksFollowList - - fun FollowPacksQueryState.listName() = listNameFlow().value - - fun FollowPacksQueryState.followsPerRelayFlow() = account.liveFollowPacksFollowListsPerRelay - - fun FollowPacksQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: FollowPacksQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.followPacksFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFilterAssemblerSubscription.kt index 349d5502c6..a8126f8e74 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFilterAssemblerSubscription.kt @@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.datasource import android.annotation.SuppressLint import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import com.vitorpamplona.amethyst.commons.relayClient.geohash.GeohashQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/GitRepositoryScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/GitRepositoryScreen.kt index f37557d1f5..afc1cf9958 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/GitRepositoryScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/GitRepositoryScreen.kt @@ -65,6 +65,7 @@ import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.nip34Git.GitBrowseState import com.vitorpamplona.amethyst.commons.nip34Git.GitRepoSnapshotCache import com.vitorpamplona.amethyst.commons.nip34Git.GitRepositoryBrowserViewModel +import com.vitorpamplona.amethyst.commons.relayClient.gitRepo.RepositoryFilterAssemblerSubscription import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.git_new_issue_button import com.vitorpamplona.amethyst.commons.resources.git_repo_bookmark @@ -96,7 +97,6 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.code.GitCodeTab import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.code.GitReadmeSection import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.dal.RepositoryIssuesFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.dal.RepositoryPatchesFeedViewModel -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.datasource.RepositoryFilterAssemblerSubscription import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilterAssemblerSubscription.kt index d43df35a33..b646c0d5f5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.GitRepositoriesFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun GitRepositoriesFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun GitRepositoriesFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - GitRepositoriesQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultGitRepositoriesFollowList, + account.liveGitRepositoriesFollowListsPerRelay, + accountViewModel.feedStates.gitRepositoriesFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesSubAssembler.kt deleted file mode 100644 index 17f8adffa3..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesSubAssembler.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class GitRepositoriesSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: GitRepositoriesQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow now resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me] against the - // user's own outbox. - val feedSettings = key.followsPerRelay() - - return makeGitRepositoriesFilter(feedSettings, since, key.feedStates.gitRepositoriesFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: GitRepositoriesQueryState) = key.account.userProfile() - - override fun list(key: GitRepositoriesQueryState) = key.listName() - - fun GitRepositoriesQueryState.listNameFlow() = account.settings.defaultGitRepositoriesFollowList - - fun GitRepositoriesQueryState.listName() = listNameFlow().value - - fun GitRepositoriesQueryState.followsPerRelayFlow() = account.liveGitRepositoriesFollowListsPerRelay - - fun GitRepositoriesQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: GitRepositoriesQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.gitRepositoriesFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt index 3efe621d54..bfd839f1fa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt @@ -20,10 +20,10 @@ */ package com.vitorpamplona.amethyst.ui.screen.loggedIn.hashtag.datasource +import com.vitorpamplona.amethyst.commons.relayClient.nip22Comments.CommentKinds import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments.CommentKinds import com.vitorpamplona.quartz.experimental.audio.header.AudioHeaderEvent import com.vitorpamplona.quartz.experimental.audio.track.AudioTrackEvent import com.vitorpamplona.quartz.experimental.interactiveStories.InteractiveStorySceneEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilterAssemblerSubscription.kt index 6f898c967a..ceab18159e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.highlights.HighlightsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun HighlightsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun HighlightsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - HighlightsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultHighlightsFollowList, + account.liveHighlightsFollowListsPerRelay, + accountViewModel.feedStates.highlightsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsSubAssembler.kt deleted file mode 100644 index b1f59a55a7..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsSubAssembler.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class HighlightsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: HighlightsQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me] against the - // user's own outbox. - val feedSettings = key.followsPerRelay() - - return makeHighlightsFilter(feedSettings, since, key.feedStates.highlightsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: HighlightsQueryState) = key.account.userProfile() - - override fun list(key: HighlightsQueryState) = key.listName() - - fun HighlightsQueryState.listNameFlow() = account.settings.defaultHighlightsFollowList - - fun HighlightsQueryState.listName() = listNameFlow().value - - fun HighlightsQueryState.followsPerRelayFlow() = account.liveHighlightsFollowListsPerRelay - - fun HighlightsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: HighlightsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.highlightsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt index 955ca478cd..ca164d6978 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt @@ -21,10 +21,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip01Core import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.nip22Comments.filterHomePostsByScopes import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments.filterHomePostsByScopes import com.vitorpamplona.quartz.experimental.attestations.attestation.AttestationEvent import com.vitorpamplona.quartz.experimental.interactiveStories.InteractiveStoryPrologueEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt index 2364f65055..7ec5adf509 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt @@ -21,10 +21,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip01Core import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.nip22Comments.filterHomePostsByScopes import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments.filterHomePostsByScopes import com.vitorpamplona.quartz.experimental.attestations.attestation.AttestationEvent import com.vitorpamplona.quartz.experimental.audio.header.AudioHeaderEvent import com.vitorpamplona.quartz.experimental.interactiveStories.InteractiveStoryPrologueEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAllFollows.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAllFollows.kt index 438cb8086f..dcb77e04b8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAllFollows.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAllFollows.kt @@ -21,10 +21,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip65Follows import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.nip22Comments.filterHomePostsByScopes import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip01Core.filterHomePostsByGeohashes import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip01Core.filterHomePostsByHashtags -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments.filterHomePostsByScopes import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip72Communities.filterHomePostsFromAllCommunities import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsFilterAssemblerSubscription.kt index 76111d1191..8def1ff279 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.livestreams.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.livestreams.LiveStreamsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun LiveStreamsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun LiveStreamsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - LiveStreamsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultLiveStreamsFollowList, + account.liveLiveStreamsFollowListsPerRelay, + accountViewModel.feedStates.liveStreamsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsSubAssembler.kt deleted file mode 100644 index c2520aa56f..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsSubAssembler.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.livestreams.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.makeLiveActivitiesFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class LiveStreamsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: LiveStreamsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeLiveActivitiesFilter(feedSettings, since, key.feedStates.liveStreamsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: LiveStreamsQueryState) = key.account.userProfile() - - override fun list(key: LiveStreamsQueryState) = key.listName() - - fun LiveStreamsQueryState.listNameFlow() = account.settings.defaultLiveStreamsFollowList - - fun LiveStreamsQueryState.listName() = listNameFlow().value - - fun LiveStreamsQueryState.followsPerRelayFlow() = account.liveLiveStreamsFollowListsPerRelay - - fun LiveStreamsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: LiveStreamsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.liveStreamsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt index 33d3da1664..6dc84b8580 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt @@ -24,6 +24,7 @@ import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.cache.filterIntoSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.video.SUPPORTED_VIDEO_FEED_MIME_TYPES_SET import com.vitorpamplona.amethyst.commons.richtext.RichTextParser import com.vitorpamplona.amethyst.commons.ui.feeds.AdditiveFeedFilter import com.vitorpamplona.amethyst.model.Account @@ -31,7 +32,6 @@ import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.dal.SupportedContent -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.SUPPORTED_VIDEO_FEED_MIME_TYPES_SET import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent import com.vitorpamplona.quartz.nip71Video.VideoMeta diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsFilterAssemblerSubscription.kt index 669ce58cce..86c19b40b0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.longs.LongsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun LongsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun LongsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - LongsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultLongsFollowList, + account.liveLongsFollowListsPerRelay, + accountViewModel.feedStates.longsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsSubAssembler.kt deleted file mode 100644 index bf76c58aef..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsSubAssembler.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class LongsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: LongsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeLongsFilter(feedSettings, since, key.feedStates.longsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: LongsQueryState) = key.account.userProfile() - - override fun list(key: LongsQueryState) = key.listName() - - fun LongsQueryState.listNameFlow() = account.settings.defaultLongsFollowList - - fun LongsQueryState.listName() = listNameFlow().value - - fun LongsQueryState.followsPerRelayFlow() = account.liveLongsFollowListsPerRelay - - fun LongsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: LongsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.longsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsFilterAssemblerSubscription.kt index 62010d5915..e105b5b9ed 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.music.MusicPlaylistsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun MusicPlaylistsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun MusicPlaylistsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - MusicPlaylistsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultMusicPlaylistsFollowList, + account.liveMusicPlaylistsFollowListsPerRelay, + accountViewModel.feedStates.musicPlaylistsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsSubAssembler.kt deleted file mode 100644 index 7d92472d5a..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsSubAssembler.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -/** - * Mirror of [MusicTracksSubAssembler] but keyed on the user's *playlists* follow list - * ([com.vitorpamplona.amethyst.model.AccountSettings.defaultMusicPlaylistsFollowList]). - * The playlists screen exposes its own top-bar spinner, and the previous setup reused the - * tracks subscription — so if the user picked, e.g., Global for playlists but Following for - * tracks, the REQ only asked Following's authors and the playlists feed showed empty. - * - * Asks for kind 34139 only — tracks referenced by playlists are loaded on demand by each - * playlist row's own per-track observer (see MusicPlaylist.kt), not bundled into this REQ. - */ -class MusicPlaylistsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: MusicPlaylistsQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow now resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me]. - val feedSettings = key.followsPerRelay() - // REQ now only asks for kind 34139 (playlists), keyed to this screen's follow - // list selector — no cross-feed cursor min needed. - return makeMusicPlaylistsFilter(feedSettings, since, key.feedStates.musicPlaylistsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: MusicPlaylistsQueryState) = key.account.userProfile() - - override fun list(key: MusicPlaylistsQueryState) = key.listName() - - fun MusicPlaylistsQueryState.listNameFlow() = account.settings.defaultMusicPlaylistsFollowList - - fun MusicPlaylistsQueryState.listName() = listNameFlow().value - - fun MusicPlaylistsQueryState.followsPerRelayFlow() = account.liveMusicPlaylistsFollowListsPerRelay - - fun MusicPlaylistsQueryState.followsPerRelay() = followsPerRelayFlow().value - - private val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: MusicPlaylistsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.musicPlaylistsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksFilterAssemblerSubscription.kt index 2672179207..c3046afa90 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.music.MusicTracksFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun MusicTracksFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun MusicTracksFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - MusicTracksQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultMusicTracksFollowList, + account.liveMusicTracksFollowListsPerRelay, + accountViewModel.feedStates.musicTracksFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksSubAssembler.kt deleted file mode 100644 index 9808be509b..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksSubAssembler.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class MusicTracksSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: MusicTracksQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow now resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me]. - val feedSettings = key.followsPerRelay() - // REQ now only asks for kind 36787 (tracks), so the `since` cursor lines up with - // the tracks feed alone — no cross-feed min needed. - return makeMusicTracksFilter(feedSettings, since, key.feedStates.musicTracksFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: MusicTracksQueryState) = key.account.userProfile() - - override fun list(key: MusicTracksQueryState) = key.listName() - - fun MusicTracksQueryState.listNameFlow() = account.settings.defaultMusicTracksFollowList - - fun MusicTracksQueryState.listName() = listNameFlow().value - - fun MusicTracksQueryState.followsPerRelayFlow() = account.liveMusicTracksFollowListsPerRelay - - fun MusicTracksQueryState.followsPerRelay() = followsPerRelayFlow().value - - private val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: MusicTracksQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.musicTracksFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsFilterAssembler.kt index 6c84bc4f13..a3770c904c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsFilterAssembler.kt @@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource import androidx.compose.runtime.Stable import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager +import com.vitorpamplona.amethyst.commons.relayClient.napplets.NappletsFilterAssembler import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsSubAssembler.kt index 308c16968f..0ef9f19a7f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/ConnectedAppsSubAssembler.kt @@ -21,8 +21,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserEoseManager +import com.vitorpamplona.amethyst.commons.relayClient.napplets.filterNappletsByAuthors import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies.filterNappletsByAuthors import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterAssembler.kt deleted file mode 100644 index fb65e94ddb..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterAssembler.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource - -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope - -/** - * Keyspace for the napplet-discovery subscription. Unlike a feed datasource it carries no - * `FeedContentState` — [com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.NappletsScreen] - * reads the manifests straight out of `LocalCache`, so this only needs the account (for relay - * selection) and a scope. - */ -class NappletsQueryState( - override val account: Account, - val scope: CoroutineScope, -) : AccountScopedQuery - -/** - * Subscribes to NIP-5D napplet manifests (kinds 15129/35129) while a napplet screen is open, - * honoring the top-nav follow-list selection at the relay level (see [NappletsFilterSubAssembler]) - * and dumping the results into `LocalCache` for the screen to observe. Registered as an app-lifetime - * singleton in `RelaySubscriptionsCoordinator` (the underlying EOSE manager opens its relay - * subscription at construction, so it must not be created per screen). - */ -@Stable -class NappletsFilterAssembler( - client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - NappletsFilterSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterAssemblerSubscription.kt index f0db726ca9..a42615c872 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterAssemblerSubscription.kt @@ -22,15 +22,19 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun NappletsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { val state = remember(accountViewModel.account) { - NappletsQueryState(accountViewModel.account, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultNappletsFollowList, + account.liveNappletsFollowListsPerRelay, + ) } LifecycleAwareKeyDataSourceSubscription(state, accountViewModel.dataSources().napplets) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterSubAssembler.kt deleted file mode 100644 index aaeb9e29e7..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/NappletsFilterSubAssembler.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -/** - * Subscribes to NIP-5D napplet manifests (kinds 15129/35129), honoring the top-nav follow-list - * selection at the relay level: one subscription per logged-in user + selected list, with the authors - * resolved to each author's outbox relays (via [com.vitorpamplona.amethyst.model.Account.liveNappletsFollowListsPerRelay]). - * Mirrors [com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.PicturesSubAssembler]; the - * only spinner options are author-based (see `authorOnlyRoutes`), so [makeNappletsFilter] needs no - * tag-based branches. - */ -class NappletsFilterSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: NappletsQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow now resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me]. - return makeNappletsFilter(key.followsPerRelay(), since) - } - - override fun user(key: NappletsQueryState) = key.account.userProfile() - - override fun list(key: NappletsQueryState) = key.listName() - - fun NappletsQueryState.listNameFlow() = account.settings.defaultNappletsFollowList - - fun NappletsQueryState.listName() = listNameFlow().value - - fun NappletsQueryState.followsPerRelayFlow() = account.liveNappletsFollowListsPerRelay - - fun NappletsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: NappletsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsFilterAssemblerSubscription.kt index 458e3a1e55..6e8bb35dd1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.nests.NestsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun NestsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun NestsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - NestsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultNestsFollowList, + account.liveNestsFollowListsPerRelay, + accountViewModel.feedStates.nestsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsSubAssembler.kt deleted file mode 100644 index 02950423e3..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsSubAssembler.kt +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -/** - * Reuses `makeLiveActivitiesFilter`, which already subscribes to kinds - * 30311/30312/30313/1311. The feed filter narrows to 30312/30313 client-side; - * sharing the wire filter avoids duplicate REQs on relays when both the Live - * Streams and Audio Rooms screens are open for the same user. - */ -class NestsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: NestsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - return makeNestsFilter(feedSettings, since, key.feedStates.nestsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: NestsQueryState) = key.account.userProfile() - - override fun list(key: NestsQueryState) = key.listName() - - fun NestsQueryState.listNameFlow() = account.settings.defaultNestsFollowList - - fun NestsQueryState.listName() = listNameFlow().value - - fun NestsQueryState.followsPerRelayFlow() = account.liveNestsFollowListsPerRelay - - fun NestsQueryState.followsPerRelay() = followsPerRelayFlow().value - - private val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: NestsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.nestsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterAssembler.kt deleted file mode 100644 index 3a1cd4098c..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterAssembler.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource - -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope - -/** - * Keyspace for the nSite-discovery subscription. Like its nApplet sibling it carries no - * `FeedContentState` — [com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.NsitesScreen] reads the - * manifests straight out of `LocalCache`, so this only needs the account (for relay selection) and a - * scope. - */ -class NsitesQueryState( - override val account: Account, - val scope: CoroutineScope, -) : AccountScopedQuery - -/** - * Subscribes to NIP-5A static-site manifests (kinds 15128/35128) while an nSite screen is open, - * honoring the top-nav follow-list selection at the relay level (see [NsitesFilterSubAssembler]) and - * dumping the results into `LocalCache` for the screen to observe. Registered as an app-lifetime - * singleton in `RelaySubscriptionsCoordinator` (the underlying EOSE manager opens its relay - * subscription at construction, so it must not be created per screen). - */ -@Stable -class NsitesFilterAssembler( - client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - NsitesFilterSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterAssemblerSubscription.kt index 7b811a670e..571252a2b9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterAssemblerSubscription.kt @@ -22,15 +22,19 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun NsitesFilterAssemblerSubscription(accountViewModel: AccountViewModel) { val state = remember(accountViewModel.account) { - NsitesQueryState(accountViewModel.account, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultNsitesFollowList, + account.liveNsitesFollowListsPerRelay, + ) } LifecycleAwareKeyDataSourceSubscription(state, accountViewModel.dataSources().nsites) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterSubAssembler.kt deleted file mode 100644 index b2d06e6991..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/NsitesFilterSubAssembler.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -/** - * Subscribes to NIP-5A static-site manifests (kinds 15128/35128), honoring the top-nav follow-list - * selection at the relay level: one subscription per logged-in user + selected list, with the authors - * resolved to each author's outbox relays (via [com.vitorpamplona.amethyst.model.Account.liveNsitesFollowListsPerRelay]). - * Mirrors [com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.PicturesSubAssembler]; the - * only spinner options are author-based (see `authorOnlyRoutes`), so [makeNsitesFilter] needs no - * tag-based branches. - */ -class NsitesFilterSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: NsitesQueryState, - since: SincePerRelayMap?, - ): List { - // "Mine" needs no special-case: the shared TopFilter.Mine flow now resolves to an author - // filter scoped to the user, so followsPerRelay() already carries authors=[me]. - return makeNsitesFilter(key.followsPerRelay(), since) - } - - override fun user(key: NsitesQueryState) = key.account.userProfile() - - override fun list(key: NsitesQueryState) = key.listName() - - fun NsitesQueryState.listNameFlow() = account.settings.defaultNsitesFollowList - - fun NsitesQueryState.listName() = listNameFlow().value - - fun NsitesQueryState.followsPerRelayFlow() = account.liveNsitesFollowListsPerRelay - - fun NsitesQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: NsitesQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesFilterAssemblerSubscription.kt index e91f3959c0..20a05f69a1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.pictures.PicturesFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun PicturesFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun PicturesFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - PicturesQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultPicturesFollowList, + account.livePicturesFollowListsPerRelay, + accountViewModel.feedStates.picturesFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesSubAssembler.kt deleted file mode 100644 index 4290e70b0f..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesSubAssembler.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class PicturesSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: PicturesQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makePicturesFilter(feedSettings, since, key.feedStates.picturesFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: PicturesQueryState) = key.account.userProfile() - - override fun list(key: PicturesQueryState) = key.listName() - - fun PicturesQueryState.listNameFlow() = account.settings.defaultPicturesFollowList - - fun PicturesQueryState.listName() = listNameFlow().value - - fun PicturesQueryState.followsPerRelayFlow() = account.livePicturesFollowListsPerRelay - - fun PicturesQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: PicturesQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.picturesFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFilterAssemblerSubscription.kt index 9fd9240b5c..da78487bf7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFilterAssemblerSubscription.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.MyPodcastQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFilterAssemblerSubscription.kt index addac70f67..aab62d65aa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFilterAssemblerSubscription.kt @@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.OnePodcastQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesFilterAssemblerSubscription.kt index 5d0ab8998c..0655abd66b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PodcastEpisodesFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun PodcastEpisodesFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun PodcastEpisodesFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - PodcastEpisodesQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultPodcastEpisodesFollowList, + account.livePodcastEpisodesFollowListsPerRelay, + accountViewModel.feedStates.podcastEpisodesFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesSubAssembler.kt deleted file mode 100644 index b8d7caa802..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesSubAssembler.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class PodcastEpisodesSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: PodcastEpisodesQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - return makePodcastEpisodesFilter(feedSettings, since, key.feedStates.podcastEpisodesFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: PodcastEpisodesQueryState) = key.account.userProfile() - - override fun list(key: PodcastEpisodesQueryState) = key.listName() - - fun PodcastEpisodesQueryState.listNameFlow() = account.settings.defaultPodcastEpisodesFollowList - - fun PodcastEpisodesQueryState.listName() = listNameFlow().value - - fun PodcastEpisodesQueryState.followsPerRelayFlow() = account.livePodcastEpisodesFollowListsPerRelay - - fun PodcastEpisodesQueryState.followsPerRelay() = followsPerRelayFlow().value - - private val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: PodcastEpisodesQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.podcastEpisodesFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsFilterAssemblerSubscription.kt index 4b8c44ab92..077cbeb95f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PodcastsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun PodcastsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun PodcastsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - PodcastsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultPodcastsFollowList, + account.livePodcastsFollowListsPerRelay, + accountViewModel.feedStates.podcastsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsSubAssembler.kt deleted file mode 100644 index cdaa70cb84..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsSubAssembler.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class PodcastsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: PodcastsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - return makePodcastsFilter(feedSettings, since, key.feedStates.podcastsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: PodcastsQueryState) = key.account.userProfile() - - override fun list(key: PodcastsQueryState) = key.listName() - - fun PodcastsQueryState.listNameFlow() = account.settings.defaultPodcastsFollowList - - fun PodcastsQueryState.listName() = listNameFlow().value - - fun PodcastsQueryState.followsPerRelayFlow() = account.livePodcastsFollowListsPerRelay - - fun PodcastsQueryState.followsPerRelay() = followsPerRelayFlow().value - - private val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: PodcastsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.podcastsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsFilterAssemblerSubscription.kt index ed74767bfb..a41910bf76 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.polls.PollsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun PollsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun PollsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - PollsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultPollsFollowList, + account.livePollsFollowListsPerRelay, + accountViewModel.feedStates.pollsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsSubAssembler.kt deleted file mode 100644 index 6d83f8347c..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsSubAssembler.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class PollsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: PollsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makePollsFilter(feedSettings, since, key.feedStates.pollsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: PollsQueryState) = key.account.userProfile() - - override fun list(key: PollsQueryState) = key.listName() - - fun PollsQueryState.listNameFlow() = account.settings.defaultPollsFollowList - - fun PollsQueryState.listName() = listNameFlow().value - - fun PollsQueryState.followsPerRelayFlow() = account.livePollsFollowListsPerRelay - - fun PollsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: PollsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.pollsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/PollResponsesFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/PollResponsesFilterAssemblerSubscription.kt index 905e75d654..cb747f4855 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/PollResponsesFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/PollResponsesFilterAssemblerSubscription.kt @@ -22,6 +22,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.results.datasources import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import com.vitorpamplona.amethyst.commons.relayClient.polls.results.PollResponsesFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.polls.results.PollResponsesQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsFilterAssemblerSubscription.kt index a722f7ac9e..cf4b391b6a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.products.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.products.ProductsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun ProductsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun ProductsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - ProductsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultProductsFollowList, + account.liveProductsFollowListsPerRelay, + accountViewModel.feedStates.productsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsSubAssembler.kt deleted file mode 100644 index cc44c0427f..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsSubAssembler.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.products.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.makeClassifiedsFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class ProductsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: ProductsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeClassifiedsFilter(feedSettings, since, key.feedStates.productsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: ProductsQueryState) = key.account.userProfile() - - override fun list(key: ProductsQueryState) = key.listName() - - fun ProductsQueryState.listNameFlow() = account.settings.defaultProductsFollowList - - fun ProductsQueryState.listName() = listNameFlow().value - - fun ProductsQueryState.followsPerRelayFlow() = account.liveProductsFollowListsPerRelay - - fun ProductsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: ProductsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.productsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt index 949e8024cf..5a55cdf4ef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt @@ -65,6 +65,7 @@ import androidx.compose.ui.unit.IntSize import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.relayClient.profile.UserProfileFilterAssemblerSubscription import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.gallery import com.vitorpamplona.amethyst.commons.resources.mutual @@ -86,7 +87,6 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.bookmarks.TabBookma import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.bookmarks.dal.UserProfileBookmarksFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.conversations.TabNotesConversations import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.conversations.dal.UserProfileConversationsFeedViewModel -import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource.UserProfileFilterAssemblerSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.followers.FollowersTabHeader import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.followers.TabFollowers import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.followers.dal.UserProfileFollowersUserFeedViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsFilterAssemblerSubscription.kt index a4f489a153..546a20c48c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.publicChats.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.publicChats.PublicChatsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun PublicChatsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun PublicChatsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - PublicChatsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultPublicChatsFollowList, + account.livePublicChatsFollowListsPerRelay, + accountViewModel.feedStates.publicChatsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsSubAssembler.kt deleted file mode 100644 index 404290bfc5..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsSubAssembler.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.publicChats.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.makePublicChatsFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class PublicChatsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: PublicChatsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makePublicChatsFilter(feedSettings, since, key.feedStates.publicChatsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: PublicChatsQueryState) = key.account.userProfile() - - override fun list(key: PublicChatsQueryState) = key.listName() - - fun PublicChatsQueryState.listNameFlow() = account.settings.defaultPublicChatsFollowList - - fun PublicChatsQueryState.listName() = listNameFlow().value - - fun PublicChatsQueryState.followsPerRelayFlow() = account.livePublicChatsFollowListsPerRelay - - fun PublicChatsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: PublicChatsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.publicChatsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterAssemblerSubscription.kt index 628e191b23..830faa9f77 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterAssemblerSubscription.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.relay.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import com.vitorpamplona.amethyst.commons.relayClient.relay.RelayFeedQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterAssemblerSubscription.kt index 8fc8d34522..15c6e42d7a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterAssemblerSubscription.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import com.vitorpamplona.amethyst.commons.relayClient.relays.RelayInfoNip66QueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt index 7f9d63800d..68e2a73f27 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt @@ -32,13 +32,13 @@ import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.commons.actions.ConcordActions import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.relayClient.search.SearchQueryState import com.vitorpamplona.amethyst.commons.search.SearchScope import com.vitorpamplona.amethyst.commons.search.SearchSortOrder import com.vitorpamplona.amethyst.commons.search.SearchSource import com.vitorpamplona.amethyst.commons.ui.feeds.InvalidatableContent import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.LocalCache -import com.vitorpamplona.amethyst.service.relayClient.searchCommand.SearchQueryState import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor @@ -104,7 +104,14 @@ class SearchBarViewModel( .onEach(::updateDataSource) .stateIn(viewModelScope, SharingStarted.Eagerly, searchValue) - val searchDataSourceState = SearchQueryState(MutableStateFlow(searchValue), account) + val searchDataSourceState = + SearchQueryState( + searchQuery = MutableStateFlow(searchValue), + account = account, + searchRelays = account.searchRelayList.flow, + indexerRelays = account.indexerRelayList.flow, + followPlusAllMineWithSearchRelays = account.followPlusAllMineWithSearch.flow, + ) @Suppress("unused") val sourceWatcher = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt index c2ec11d7c6..4683322742 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt @@ -24,6 +24,7 @@ import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.cache.filterIntoSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.video.SUPPORTED_VIDEO_FEED_MIME_TYPES_SET import com.vitorpamplona.amethyst.commons.richtext.RichTextParser import com.vitorpamplona.amethyst.commons.ui.feeds.AdditiveFeedFilter import com.vitorpamplona.amethyst.model.Account @@ -31,7 +32,6 @@ import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.dal.SupportedContent -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.SUPPORTED_VIDEO_FEED_MIME_TYPES_SET import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip71Video.VideoMeta import com.vitorpamplona.quartz.nip71Video.VideoShortEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsFilterAssemblerSubscription.kt index 3af1d674fd..6f70c1c077 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.shorts.ShortsFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun ShortsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun ShortsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - ShortsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultShortsFollowList, + account.liveShortsFollowListsPerRelay, + accountViewModel.feedStates.shortsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsSubAssembler.kt deleted file mode 100644 index d50f3ae83d..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsSubAssembler.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class ShortsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: ShortsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeShortsFilter(feedSettings, since, key.feedStates.shortsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: ShortsQueryState) = key.account.userProfile() - - override fun list(key: ShortsQueryState) = key.listName() - - fun ShortsQueryState.listNameFlow() = account.settings.defaultShortsFollowList - - fun ShortsQueryState.listName() = listNameFlow().value - - fun ShortsQueryState.followsPerRelayFlow() = account.liveShortsFollowListsPerRelay - - fun ShortsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: ShortsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.shortsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsFilterAssemblerSubscription.kt index bee8038459..367116517e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsFilterAssemblerSubscription.kt @@ -23,6 +23,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.lifecycle.viewModelScope +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.SoftwareAppsFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.SoftwareAppsQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -41,7 +43,15 @@ fun SoftwareAppsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - SoftwareAppsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + SoftwareAppsQueryState( + account = account, + listName = account.settings.defaultSoftwareAppsFollowList, + followsPerRelay = account.liveSoftwareAppsFollowListsPerRelay, + scope = accountViewModel.viewModelScope, + feed = accountViewModel.feedStates.softwareAppsFeed, + blockedRelays = account.blockedRelayList.flow, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsSubAssembler.kt deleted file mode 100644 index 57845da77e..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsSubAssembler.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class SoftwareAppsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: SoftwareAppsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeSoftwareAppsFilter( - feedSettings, - since, - key.feedStates.softwareAppsFeed.lastNoteCreatedAtIfFilled(), - key.account.blockedRelayList.flow.value, - ) - } - - override fun user(key: SoftwareAppsQueryState) = key.account.userProfile() - - override fun list(key: SoftwareAppsQueryState) = key.listName() - - fun SoftwareAppsQueryState.listNameFlow() = account.settings.defaultSoftwareAppsFollowList - - fun SoftwareAppsQueryState.listName() = listNameFlow().value - - fun SoftwareAppsQueryState.followsPerRelayFlow() = account.liveSoftwareAppsFollowListsPerRelay - - fun SoftwareAppsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: SoftwareAppsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - // Re-evaluate when the user blocks/unblocks zapstore's relay so the - // global Apps feed stops/starts querying it without a restart. - key.account.blockedRelayList.flow.collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.softwareAppsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadEventLoaderSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadEventLoaderSubAssembler.kt index 465a210f79..e20a7df4a9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadEventLoaderSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadEventLoaderSubAssembler.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.threadview.datasources.sub import com.vitorpamplona.amethyst.commons.model.ThreadAssembler import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager +import com.vitorpamplona.amethyst.commons.relayClient.thread.filterMissingEventsForThread import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.ui.screen.loggedIn.threadview.datasources.ThreadQueryState @@ -48,7 +49,7 @@ class ThreadEventLoaderSubAssembler( ): List? { val branches = ThreadAssembler(LocalCache).findThreadFor(key.eventId) ?: return null val defaultRelays = key.account.followPlusAllMineWithSearch.flow.value - return filterMissingEventsForThread(branches, defaultRelays) + return filterMissingEventsForThread(LocalCache, branches, defaultRelays) } override fun id(key: ThreadQueryState) = key.eventId diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadFilterSubAssembler.kt index 102b0f94cd..cd26d02df2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadFilterSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/ThreadFilterSubAssembler.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.threadview.datasources.sub import com.vitorpamplona.amethyst.commons.model.ThreadAssembler import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager +import com.vitorpamplona.amethyst.commons.relayClient.thread.filterEventsInThreadForRoot import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.ui.screen.loggedIn.threadview.datasources.ThreadQueryState diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFilterAssemblerSubscription.kt index 8817f71eb7..86365e6b4c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFilterAssemblerSubscription.kt @@ -24,6 +24,7 @@ import android.annotation.SuppressLint import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription +import com.vitorpamplona.amethyst.commons.relayClient.url.UrlQueryState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @SuppressLint("StateFlowValueCalledInComposition") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt index 90e13d6d11..462c21afdd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt @@ -24,13 +24,13 @@ import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.cache.filterIntoSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.video.SUPPORTED_VIDEO_FEED_MIME_TYPES_SET import com.vitorpamplona.amethyst.commons.richtext.RichTextParser import com.vitorpamplona.amethyst.commons.ui.feeds.AdditiveFeedFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.SUPPORTED_VIDEO_FEED_MIME_TYPES_SET import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip68Picture.PictureMeta diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssembler.kt deleted file mode 100644 index f72d9e9212..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssembler.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource - -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.VideoOutboxEventsFilterSubAssembler -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope - -// This allows multiple screen to be listening to tags, even the same tag -class VideoQueryState( - override val account: Account, - val feedState: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -class VideoFilterAssembler( - client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - VideoOutboxEventsFilterSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt index dabf9ec722..239c759804 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription +import com.vitorpamplona.amethyst.commons.relayClient.video.VideoFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun VideoFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -43,7 +44,12 @@ fun VideoFilterAssemblerSubscription( // even if they are tracking the same tag. val state = remember(accountViewModel.account) { - VideoQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultStoriesFollowList, + account.liveStoriesFollowListsPerRelay, + accountViewModel.feedStates.videoFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, filterAssembler) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/VideoOutboxEventsFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/VideoOutboxEventsFilterSubAssembler.kt deleted file mode 100644 index aa10582f74..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/VideoOutboxEventsFilterSubAssembler.kt +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.VideoQueryState -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core.filterPictureAndVideoByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core.filterPictureAndVideoByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core.filterPictureAndVideoGlobal -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip65Follows.filterPictureAndVideoByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip65Follows.filterPictureAndVideoByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip72Communities.filterPictureAndVideoByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip72Communities.filterPictureAndVideoByCommunity -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import com.vitorpamplona.quartz.utils.TimeUtils -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class VideoOutboxEventsFilterSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: VideoQueryState, - since: SincePerRelayMap?, - ): List? { - val feedSettings = key.followsPerRelay() - val defaultSince = key.feedState.videoFeed.lastNoteCreatedAtWhenFullyLoaded.value - return when (feedSettings) { - is AllCommunitiesTopNavPerRelayFilterSet -> filterPictureAndVideoByAllCommunities(feedSettings, since, defaultSince) - is AllFollowsTopNavPerRelayFilterSet -> filterPictureAndVideoByFollows(feedSettings, since, defaultSince) - is AuthorsTopNavPerRelayFilterSet -> filterPictureAndVideoByAuthors(feedSettings, since, defaultSince) - is GlobalTopNavPerRelayFilterSet -> filterPictureAndVideoGlobal(feedSettings, since, defaultSince ?: TimeUtils.oneWeekAgo()) - is HashtagTopNavPerRelayFilterSet -> filterPictureAndVideoByHashtag(feedSettings, since, defaultSince ?: TimeUtils.oneMonthAgo()) - is LocationTopNavPerRelayFilterSet -> filterPictureAndVideoByGeohash(feedSettings, since, defaultSince) - is MutedAuthorsTopNavPerRelayFilterSet -> filterPictureAndVideoByAuthors(feedSettings, since, defaultSince) - is SingleCommunityTopNavPerRelayFilterSet -> filterPictureAndVideoByCommunity(feedSettings, since, defaultSince) - else -> emptyList() - } - } - - override fun user(key: VideoQueryState) = key.account.userProfile() - - override fun list(key: VideoQueryState) = key.listName() - - fun VideoQueryState.listNameFlow() = account.settings.defaultStoriesFollowList - - fun VideoQueryState.listName() = listNameFlow().value - - fun VideoQueryState.followsPerRelayFlow() = account.liveStoriesFollowListsPerRelay - - fun VideoQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: VideoQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(1000).collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.feedState.videoFeed.lastNoteCreatedAtWhenFullyLoaded.sample(1000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/datasource/OnchainZapsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/datasource/OnchainZapsFilterAssemblerSubscription.kt index fc489d2329..efe1a1bb00 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/datasource/OnchainZapsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/datasource/OnchainZapsFilterAssemblerSubscription.kt @@ -24,6 +24,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription +import com.vitorpamplona.amethyst.commons.relayClient.wallet.OnchainZapsQueryState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsFilterAssemblerSubscription.kt index 69bf6db70b..faa5417f61 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsFilterAssemblerSubscription.kt @@ -22,9 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.LifecycleAwareKeyDataSourceSubscription +import com.vitorpamplona.amethyst.commons.relayClient.workouts.WorkoutsFilterAssembler import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.topNavFeedQueryState @Composable fun WorkoutsFilterAssemblerSubscription(accountViewModel: AccountViewModel) { @@ -41,7 +42,12 @@ fun WorkoutsFilterAssemblerSubscription( ) { val state = remember(accountViewModel.account) { - WorkoutsQueryState(accountViewModel.account, accountViewModel.feedStates, accountViewModel.viewModelScope) + val account = accountViewModel.account + accountViewModel.topNavFeedQueryState( + account.settings.defaultWorkoutsFollowList, + account.liveWorkoutsFollowListsPerRelay, + accountViewModel.feedStates.workoutsFeed, + ) } LifecycleAwareKeyDataSourceSubscription(state, dataSource) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsSubAssembler.kt deleted file mode 100644 index 7a6bd8dc10..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsSubAssembler.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource - -import com.vitorpamplona.amethyst.commons.model.User -import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter -import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager -import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.sample -import kotlinx.coroutines.launch - -class WorkoutsSubAssembler( - client: INostrClient, - allKeys: () -> Set, -) : PerUserAndFollowListEoseManager(client, allKeys) { - override fun updateFilter( - key: WorkoutsQueryState, - since: SincePerRelayMap?, - ): List { - val feedSettings = key.followsPerRelay() - - return makeWorkoutsFilter(feedSettings, since, key.feedStates.workoutsFeed.lastNoteCreatedAtIfFilled()) - } - - override fun user(key: WorkoutsQueryState) = key.account.userProfile() - - override fun list(key: WorkoutsQueryState) = key.listName() - - fun WorkoutsQueryState.listNameFlow() = account.settings.defaultWorkoutsFollowList - - fun WorkoutsQueryState.listName() = listNameFlow().value - - fun WorkoutsQueryState.followsPerRelayFlow() = account.liveWorkoutsFollowListsPerRelay - - fun WorkoutsQueryState.followsPerRelay() = followsPerRelayFlow().value - - val userJobMap = mutableMapOf>() - - @OptIn(FlowPreview::class) - override fun newSub(key: WorkoutsQueryState): Subscription { - val user = user(key) - userJobMap[user]?.forEach { it.cancel() } - userJobMap[user] = - listOf( - key.scope.launch(Dispatchers.IO) { - key.listNameFlow().collectLatest { - invalidateFilters() - } - }, - key.scope.launch(Dispatchers.IO) { - key.followsPerRelayFlow().sample(500).collectLatest { - invalidateFilters() - } - }, - key.account.scope.launch(Dispatchers.IO) { - key.feedStates.workoutsFeed.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { - invalidateFilters() - } - }, - ) - - return super.newSub(key) - } - - override fun endSub( - key: User, - subId: String, - ) { - super.endSub(key, subId) - userJobMap[key]?.forEach { it.cancel() } - } -} diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzTimelineKindsTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzTimelineKindsTest.kt index f189e58d32..74b74e0ba6 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzTimelineKindsTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/BuzzTimelineKindsTest.kt @@ -20,6 +20,11 @@ */ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.BUZZ_RELAY_GROUP_TIMELINE_EXTRA_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_ALL_TIMELINE_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_TIMELINE_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupJoinedChatTailFilter +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.buildRelayGroupOpenChatTailFilter import com.vitorpamplona.quartz.buzz.stream.StreamMessageV2Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip29RelayGroups.GroupId diff --git a/commons/plans/2026-08-30-commons-migration-sweep.md b/commons/plans/2026-08-30-commons-migration-sweep.md index 13666d8214..65c8a3835e 100644 --- a/commons/plans/2026-08-30-commons-migration-sweep.md +++ b/commons/plans/2026-08-30-commons-migration-sweep.md @@ -353,7 +353,8 @@ formatters). shims; land Batches 1-5 above (~350 files) — no refactoring required. 2. **Wave 1 (three small edits, huge fan-out):** finish `EOSE.kt`; `IFeedTopNavFilter` → `ICacheProvider`; add KMP `LruCache` expect. - Unlocks subassemblies (145), topNavFeeds (23), caches (5). + Unlocks subassemblies (145 — **landed 2026-09-05**, see the handoff + below), topNavFeeds (23), caches (5). 3. **Wave 2 (ports):** extract `TopFilter` + `ListBackupStore` from `AccountSettings`; move `LocalCache` behind its 3 tiny expects. Unlocks nip51Lists, the nipNN state packages, serverList/userMetadata, @@ -558,6 +559,189 @@ Original findings, for reference: `CoilImageBridge.jvm.kt` and `.ios.kt` — hoist to a shared Skiko source set. +### Batch 2 landed — subassemblies are in `commons/relayClient` (2026-09-05) + +The audit's Batch 2 (the `ui/screen/**/subassemblies/` filter functions) was +never executed by the earlier waves; it is done now on branch +`claude/amethyst-commons-migration-ua8ma8`. What moved and where: + +- All 161 subassembly files → `commons/relayClient//…`, with the + `subassemblies` path segment dropped to match how Batch 1 landed + (`relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt`). Mapping: + `searchCommand/subassemblies` → `relayClient/search`, + `chats/publicChannels/datasource/subassemblies` → `relayClient/channel`, + `…/relayGroup/datasource/subassemblies` → `relayClient/channel/relayGroup`, + `discover//subassemblies` → `relayClient/discover/`, and + `/datasource/subassemblies[/]` → `relayClient/[/]`. + The misnamed `shorts/…/FilterPollsByAllCommunities.kt` became + `FilterShortsByAllCommunities.kt` on the way. +- Pure companions the 161 needed, moved alongside: `video/datasource/FeedBasis.kt` + (the picture/video kind lists) → `relayClient/video`, and + `relayGroup/datasource/RelayGroupFilterBuilders.kt` (+ its test) → + `relayClient/channel/relayGroup`. The two `*_PAGE_LIMIT` consts went to + `relayClient/nsites` / `relayClient/napplets`. +- The three query-state keys the sub-assemblers are typed on now live in commons + on `IAccount`: `ChannelQueryState` (unchanged shape), + `SearchQueryState` (carries the search / indexer / follow-plus-mine relay + sets as `StateFlow`s instead of reaching into `Account`), and + `VideoQueryState` (carries `listName`, `followsPerRelay` and + `lastNoteCreatedAtWhenFullyLoaded` flows instead of `Account` + + `AccountFeedContentStates`). The app constructs them in + `SearchBarViewModel`, `UserSuggestionState` and + `VideoFilterAssemblerSubscription`; the `*FilterAssembler` classes stayed in + the app (they are now import-clean and can follow with the datasource batch). +- `ICacheProvider` grew the seams the six `LocalCache`-coupled files needed: + `consume(nip19: Entity)` (hint + placeholder seeding for a search query), + `allRelayGroupChannels()` and `getRelayGroupChannelsOnRelay(relay)`. + `DesktopLocalCache` implements them (relay groups: empty, desktop has no + NIP-29 cache yet). `filterByAuthor/Event/Address` and the set-level + `filterRelayGroupsBy{Authors,MutedAuthors,Follows}` + + `filterRelayGroupsDiscovery` take `cache: ICacheProvider` as their first + parameter; the per-relay `filterRelayGroupsByAuthors` lost its `LocalCache` + default for `cachedChannels` (the test always passed it explicitly). +- The four tests moved to `commons/src/commonTest` on `kotlin.test` (JUnit's + message-first asserts were reordered). + +Not done on purpose: the `SubAssemblyHelper.kt` / `*Filter.kt` dispatchers and +the `*FilterAssembler` / `*Subscription` classes in each `datasource` package — +they are the datasource batch (333 files, 102 of them `Account`/ +`AccountViewModel`-coupled) and belong with Wave 4. Desktop's +`subscriptions/FilterBuilders.kt` (742 lines of hand-rolled copies of these +filters) is now deletable in favour of the commons functions — a desktop +follow-up, not part of this batch. + +### Top-nav feed datasource layer landed in `commons/relayClient` (2026-09-05) + +The family that dispatches to the Batch-2 filters — 26 `XFilterAssembler` + +`XSubAssembler` + `XQueryState` triples, one per top-nav feed (polls, +pictures, longs, badges, nests, podcasts ×2, music ×2, discover, …) — was 26 +copies of the same ~90 lines differing only in the `makeXFilter` dispatcher and +which `FeedContentState` floor bounds `since`. Moving the copies would have +relocated the duplication, so they collapsed onto three shared classes in +`commons/relayClient/topNavFeeds/`: + +- `TopNavFeedQueryState(account: IAccount, listName, followsPerRelay, scope, + feeds)` — the one key type for all of them (open; `DiscoveryQueryState` + adds its seven named tabs, `SoftwareAppsQueryState` adds the blocked-relay + set). +- `TopNavFeedSubAssembler` — the abstract EOSE manager carrying the shared + job wiring (list-name watcher, per-relay follows sampled at 500 ms, feed + floors combined and sampled at 5 s, plus `onListChanged` / + `extraInvalidators` hooks). `SingleTopNavFeedSubAssembler(client, keys, + ::makeXFilter, resetEoseOnListChange)` is the concrete one every + single-dispatcher feed uses; Discovery's three and SoftwareApps' one are + subclasses. +- `TopNavFeedFilterAssembler` — the `ComposeSubscriptionManager` that owns + the sub-assemblers. Each feature keeps a one-line + `commons/relayClient//XFilterAssembler.kt` naming its dispatcher, + so `RelaySubscriptionsCoordinator` and the `*Subscription` composables kept + their types and names. + +The pure `makeXFilter` dispatchers (`SubAssemblyHelper.kt`, `XFilter.kt`, +`FilterBadges.kt`, the seven `discover//SubAssemblyHelper.kt`) moved next +to their filters. What stays in the app is exactly the Compose glue: each +`XFilterAssemblerSubscription.kt` now builds the key with +`AccountViewModel.topNavFeedQueryState(listName, followsPerRelay, feed…)` +(`ui/screen/loggedIn/TopNavFeedQueryStates.kt`), reading the `Account` / +`AccountSettings` / `AccountFeedContentStates` fields there. + +Deliberate behaviour deltas, all small: every watcher now runs on the key's +(screen) scope — the floor watcher used to run on `account.scope`; the +per-relay-follows sampler is 500 ms everywhere (Discovery tab 2 and Video had +1000 ms); Video gained the list-name watcher the others always had, and its +inline `when` became `makePictureAndVideoFilter`. `VideoQueryState` from the +previous batch is gone in favour of the shared key. + +**Not in this batch** — the datasource files with other key shapes: +`RelayGroupsDiscovery*` (reads `LocalCache.live.newEventBundles` and the +relay-group server lists), `home/` (its filters are still app-side and +`HomeOutboxEventsEoseManager` is a different animal), and the non-top-nav +families (profile, thread, chatroom(s), hashtag, geohash, url, relay feed, +community, gitRepo, chess, one/my podcast, connectedApps, profile badges, app +recommendations, nest room, follow-pack feed, onchain zaps, NIP-66 relay +info). Many are import-clean and can follow mechanically; the `Account`-typed +ones wait on Wave 4. + +### Import-clean non-top-nav datasource families landed (2026-09-05) + +The families whose keys are a `User`, an `AddressableNote`, a string, or an +`IAccount`-compatible account moved wholesale into `commons/relayClient/`: +chess, relay feed, NIP-66 relay info, url, geohash, the channel assembler, +communities, git repo, profile (all 14 files), one/my podcast, onchain zaps, +poll responses, plus the pure `filterEventsInThreadForRoot` / +`filterMissingEventsForThread` functions and `FilterPostsByScopes.kt` +(`CommentKinds`), which those filters and the home feed share. The URL filter +test came along onto `kotlin.test`. Three Subscription composables that never +touched `AccountViewModel` (community, repository, profile) moved too. + +The only seam was `LocalCache`, read for `relayHints` and +`checkGetOrCreateUser` — both already on `ICacheProvider` — so the affected +assemblers take `cache: ICacheProvider` as their first constructor parameter, +thread it into their sub-assemblers, and the filter functions that need it +take it as their first parameter. `RelaySubscriptionsCoordinator` passes the +cache it already holds. + +Still in the app, with the reason: `hashtag/` (`FilterHashtagLabels` reads +`Account.followsPerRelay`, a per-outbox follow resolution `IAccount` lacks); +`threadview/datasources/` assembler + sub-assemblers and `apps/recommendations`, +`badges/profile`, `napplets/ConnectedApps*` (each reads one relay-list state +off `Account` — `followPlusAllMineWithSearch`, `outboxRelays` / +`defaultGlobalRelays`, `notificationRelays`, `homeRelays`; the +`SearchQueryState` recipe of carrying the flow on the key applies, one small +change each); `followPacks/feed` (dispatches to the app-side home filters); +`chats/*` (DM plumbing: `DmRelayLog`, `GeohashRelays`, +`launchChatFeedToggleObserver`); `nests/NestRoom*`, `relayGroup/*`, `concord/*` +and `home/` (`Account` + `LocalCache` live streams + `AccountViewModel`). + +### Desktop `subscriptions/FilterBuilders.kt` — investigated, not migrated (2026-09-05) + +The audit listed this 742-line file as a hand-rolled copy of ~34 +subassemblies that the Batch-2 move would make deletable. That premise is +wrong, and the two sides do not share a model: + +- **Desktop** builds plain quartz `Filter`s and broadcasts the same list to a + whole relay set (`RelayConnectionManager.subscribe` does + `relays.associateWith { filters }`; relay choice is "all connected/configured + relays"). No per-relay `since`, no EOSE bookkeeping, no `SubPurpose`. +- **Commons** builds `List` — one `ExplainedFilter` per relay + — from an `IFeedTopNavPerRelayFilterSet` the outbox model derives from + follow lists + each author's NIP-65 write relays, with `since` per relay + from the EOSE managers, driven by `ComposeSubscriptionManager`. +- Both end in the same quartz call, `NostrClient.subscribe(subId, + Map>)`; the mismatch is one layer up (who picks the + relay per filter, where `since` lives). + +What the file actually is: 27 functions, 6 with no callers at all +(`nip04DmsToUser/FromUser`, `giftWrapsToUser`, `dmRelayList`, +`chessChallengesToUser`, `chessAllEvents`); a 90-line `buildFilter` DSL used +only by its own 525-line test; most of the rest are one-line named-argument +wrappers over the `Filter` constructor with hard-coded kind integers +(`listOf(0)`, `9735`, `30023`, `30064`…). The genuine overlaps with commons are +the search kind groups (`SearchFilterFactory` says "ported from Android +SearchPostsByText"; commons now exports `SearchPostsByTextKinds1..3`), the +chess filters (commons `nip64Chess/subscription/ChessFilterBuilder` has +`challengesFilter`/`userGamesFilter`/`userTaggedFilter`), and +`notificationsForUser`, which already delegates to commons. + +Options, for the maintainer to pick: + +1. **Adapter, partial match** — teach `SubscriptionConfig` / + `RelayConnectionManager` to accept `List` (group by relay + into the map) so desktop can call commons functions with a uniform set, + e.g. `GlobalTopNavPerRelayFilterSet(relays.associateWith { + GlobalTopNavPerRelayFilter })` or an `AuthorsTopNavPerRelayFilterSet` from + the follow list. Reuses the shared filter shapes and deletes most of + `FilterBuilders`; keeps desktop's broadcast relay policy and `since = null`. + Prerequisite for (2). **Recommended next step.** +2. **Adopt the outbox model, full match** — desktop builds filter sets via + commons `OutboxLoaderState` (needs the users' NIP-65 lists in its cache) and + drives subscriptions through the commons EOSE + subscription managers. This + is the Wave-2/`DesktopLocalCache` direction; a project, not a cleanup. +3. **No model change** — inline the trivial wrappers as `Filter(...)` with + quartz kind constants, delete the dead functions and the test-only DSL, + switch search/chess to the commons functions. Removes the file, gains no + routing parity. + ### Next work, in recommended order (needs maintainer go-ahead per item) - **Tier 4 unlocks** (small, mechanical): `NappletProtocolJson` diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/ICacheProvider.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/ICacheProvider.kt index 9d2345a700..16570d3d22 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/ICacheProvider.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/ICacheProvider.kt @@ -24,10 +24,20 @@ import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Channel import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.hints.HintIndexer +import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip19Bech32.entities.Entity +import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress +import com.vitorpamplona.quartz.nip19Bech32.entities.NEmbed +import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent +import com.vitorpamplona.quartz.nip19Bech32.entities.NNote +import com.vitorpamplona.quartz.nip19Bech32.entities.NProfile +import com.vitorpamplona.quartz.nip19Bech32.entities.NPub +import com.vitorpamplona.quartz.nip19Bech32.entities.NSec import com.vitorpamplona.quartz.utils.Log /** @@ -167,4 +177,51 @@ interface ICacheProvider { fun checkGetOrCreateUser(key: HexKey): User? = runCatching { getOrCreateUser(key) }.getOrNull() fun justConsumeMyOwnEvent(event: Event): Boolean + + /** + * Seeds the cache from a parsed NIP-19 entity: records its relay hints and creates the + * placeholder User / Note / AddressableNote, so a REQ built for it has something to + * attach to. Used by the search sub-assemblers when the query is an npub/nevent/naddr. + */ + fun consume(nip19: Entity) { + when (nip19) { + is NSec -> getOrCreateUser(nip19.toPubKeyHex()) + is NPub -> getOrCreateUser(nip19.hex) + is NProfile -> { + nip19.relay.forEach { relayHints.addKey(nip19.hex, it) } + getOrCreateUser(nip19.hex) + } + is NNote -> checkGetOrCreateNote(nip19.hex) + is NEvent -> { + nip19.relay.forEach { relayHints.addEvent(nip19.hex, it) } + val note = checkGetOrCreateNote(nip19.hex) + if (note != null && note.author == null) { + nip19.author?.let { note.author = checkGetOrCreateUser(it) } + } + } + is NEmbed -> consumeEmbedded(nip19.event) + is NAddress -> { + val aTag = nip19.aTag() + nip19.relay.forEach { relayHints.addAddress(aTag, it) } + getOrCreateAddressableNote(nip19.address()) + } + else -> {} + } + } + + /** + * Ingests an event carried inline in an `nembed`. Unlike [justConsumeMyOwnEvent] the event + * did not come from this user, so implementations verify its signature like a relay event. + */ + fun consumeEmbedded(event: Event) + + /** + * Every NIP-29 relay group (kind 39000 metadata + rosters) this cache holds. The discovery + * filters read it to back-fill metadata for groups whose roster names a follow. Defaults to + * empty for a cache with no relay-group support (Desktop today, test stubs). + */ + fun allRelayGroupChannels(): List = emptyList() + + /** The subset of [allRelayGroupChannels] hosted on [relay]. */ + fun getRelayGroupChannelsOnRelay(relay: NormalizedRelayUrl): List = allRelayGroupChannels().filter { it.groupId.relayUrl == relay } } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/articles/ArticlesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/articles/ArticlesFilterAssembler.kt new file mode 100644 index 0000000000..e4f1d7c4a5 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/articles/ArticlesFilterAssembler.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.articles + +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.makeLongFormFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient + +class ArticlesFilterAssembler( + client: INostrClient, +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeLongFormFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/badges/BadgesFilterAssembler.kt similarity index 56% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/badges/BadgesFilterAssembler.kt index 6df4f04dd2..27e21fd65b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/BadgesFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/badges/BadgesFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.badges.datasource +package com.vitorpamplona.amethyst.commons.relayClient.badges -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class BadgesQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class BadgesFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - BadgesSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeBadgesFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/FilterBadges.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/badges/FilterBadges.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/FilterBadges.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/badges/FilterBadges.kt index 76369c2f55..d0289d6d2c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/badges/datasource/FilterBadges.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/badges/FilterBadges.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.badges.datasource +package com.vitorpamplona.amethyst.commons.relayClient.badges import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/CalendarKinds.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarKinds.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/CalendarKinds.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarKinds.kt index 369ea047c1..80846f47b5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/CalendarKinds.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarKinds.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarsFilterAssembler.kt index 1a9e01a208..d95c70b728 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/CalendarsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarsFilterAssembler.kt @@ -18,34 +18,17 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource +package com.vitorpamplona.amethyst.commons.relayClient.calendars -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class CalendarsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable +/** + * Calendar events are addressables the cache holds only weakly, so switching lists resets the EOSE + * cursor (see [SingleTopNavFeedSubAssembler]). + */ class CalendarsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - CalendarsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeCalendarsFilter, resetEoseOnListChange = true)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByAuthors.kt index 07ae6e30d5..f7dc60e45c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByFollows.kt index c12c02f39c..e0a9d2e18f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByGeohashes.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByGeohashes.kt index d18e46b3a9..73b5c6e3ec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByHashtag.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByHashtag.kt index 977f45da0f..6fe21c2020 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsGlobal.kt index 94ecdf61d5..b30c41a2b0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/subassemblies/FilterCalendarsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/FilterCalendarsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/SubAssemblyHelper.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/SubAssemblyHelper.kt index fb01c7d305..e90c87015b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource +package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -27,14 +27,14 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavP import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.calendars.filterCalendarsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.calendars.filterCalendarsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.calendars.filterCalendarsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.calendars.filterCalendarsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.calendars.filterCalendarsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.calendars.filterCalendarsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies.filterCalendarsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies.filterCalendarsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies.filterCalendarsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies.filterCalendarsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies.filterCalendarsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.datasource.subassemblies.filterCalendarsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeCalendarsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/ChannelFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelFilterAssembler.kt similarity index 75% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/ChannelFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelFilterAssembler.kt index 3edc54fdb2..7100eb5c8f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/ChannelFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelFilterAssembler.kt @@ -18,21 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource +package com.vitorpamplona.amethyst.commons.relayClient.channel -import com.vitorpamplona.amethyst.commons.model.Channel +import com.vitorpamplona.amethyst.commons.relayClient.channel.ChannelFromUserFilterSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.channel.ChannelPublicFilterSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.channel.ChannelQueryState import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies.ChannelFromUserFilterSubAssembler -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies.ChannelPublicFilterSubAssembler import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -// This allows multiple screen to be listening to tags, even the same tag -class ChannelQueryState( - var channel: Channel, - var account: Account, -) - class ChannelFilterAssembler( client: INostrClient, ) : ComposeSubscriptionManager() { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/ChannelFromUserFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelFromUserFilterSubAssembler.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/ChannelFromUserFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelFromUserFilterSubAssembler.kt index cdee3fca1e..382347b81d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/ChannelFromUserFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelFromUserFilterSubAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.Channel import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel @@ -27,7 +27,6 @@ import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChann import com.vitorpamplona.amethyst.commons.model.nip53LiveActivities.LiveActivitiesChannel import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.ChannelQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/ChannelPublicFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelPublicFilterSubAssembler.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/ChannelPublicFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelPublicFilterSubAssembler.kt index e9a3e73446..bd5224bf9b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/ChannelPublicFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelPublicFilterSubAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.Channel import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel @@ -28,7 +28,6 @@ import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChann import com.vitorpamplona.amethyst.commons.model.nip53LiveActivities.LiveActivitiesChannel import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.ChannelQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelQueryState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelQueryState.kt new file mode 100644 index 0000000000..65f7730de1 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/ChannelQueryState.kt @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.channel + +import com.vitorpamplona.amethyst.commons.model.Channel +import com.vitorpamplona.amethyst.commons.model.IAccount +import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery + +/** + * One screen's interest in a channel's messages. Several screens may watch the same + * channel at once, so each gets its own key rather than sharing one per channel. + */ +class ChannelQueryState( + val channel: Channel, + override val account: IAccount, +) : AccountScopedQuery diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterGoalForLiveActivity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterGoalForLiveActivity.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterGoalForLiveActivity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterGoalForLiveActivity.kt index b5f5951e9a..66f6929113 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterGoalForLiveActivity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterGoalForLiveActivity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.nip53LiveActivities.LiveActivitiesChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToEphemeralChat.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToEphemeralChat.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToEphemeralChat.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToEphemeralChat.kt index 0dc5d39281..b361c4ce86 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToEphemeralChat.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToEphemeralChat.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToGeohashChat.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToGeohashChat.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToGeohashChat.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToGeohashChat.kt index 2b43974bda..8721873f4e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToGeohashChat.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToGeohashChat.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.geohashChat.GeohashChatChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToLiveStream.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToLiveStream.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToLiveStream.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToLiveStream.kt index 7fe1dcbaad..a065038175 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToLiveStream.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToLiveStream.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.nip53LiveActivities.LiveActivitiesChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToPublicChat.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToPublicChat.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToPublicChat.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToPublicChat.kt index 840f35fff6..f5dcf80112 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMessagesToPublicChat.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToPublicChat.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.nip28PublicChats.PublicChatChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToEphemeralChat.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToEphemeralChat.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToEphemeralChat.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToEphemeralChat.kt index 408b67a056..4081669fe5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToEphemeralChat.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToEphemeralChat.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToLiveActivities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToLiveActivities.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToLiveActivities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToLiveActivities.kt index db30cfc704..c7f61ff90b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToLiveActivities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToLiveActivities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.nip53LiveActivities.LiveActivitiesChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToPublicChat.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToPublicChat.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToPublicChat.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToPublicChat.kt index 3ed65340e8..d0bc54d53b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterMyMessagesToPublicChat.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMyMessagesToPublicChat.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.nip28PublicChats.PublicChatChannel import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterRelayGroupState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupState.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterRelayGroupState.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupState.kt index 8e47c7249c..455927d5d8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterRelayGroupState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupState.kt @@ -18,14 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_METADATA_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup.RELAY_GROUP_PIN_KINDS import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RELAY_GROUP_METADATA_KINDS -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RELAY_GROUP_PIN_KINDS import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByAuthors.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByAuthors.kt index 35c72f33e9..e7b1f3ca3c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByAuthors.kt @@ -18,15 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl @@ -37,10 +37,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent /** One scan of the group cache, grouped by host relay — reused across every relay in a filter set. */ -fun relayGroupChannelsByRelay(): Map> = - LocalCache.relayGroupChannels - .filter { _, _ -> true } - .groupBy { it.groupId.relayUrl } +fun relayGroupChannelsByRelay(cache: ICacheProvider): Map> = cache.allRelayGroupChannels().groupBy { it.groupId.relayUrl } /** * A group's kind-39000 is relay-signed, so a follow shows up in three distinct ways, and each is a @@ -58,7 +55,7 @@ fun filterRelayGroupsByAuthors( relay: NormalizedRelayUrl, authors: Set, since: Long? = null, - cachedChannels: List = LocalCache.getRelayGroupChannelsOnRelay(relay), + cachedChannels: List, ): List { if (authors.isEmpty()) return emptyList() val authorList = authors.sorted() @@ -115,13 +112,14 @@ fun filterRelayGroupsByAuthors( } fun filterRelayGroupsByAuthors( + cache: ICacheProvider, authorSet: AuthorsTopNavPerRelayFilterSet, since: SincePerRelayMap?, defaultSince: Long? = null, ): List { if (authorSet.set.isEmpty()) return emptyList() - val channelsByRelay = relayGroupChannelsByRelay() + val channelsByRelay = relayGroupChannelsByRelay(cache) return authorSet.set.flatMap { filterRelayGroupsByAuthors( relay = it.key, @@ -133,13 +131,14 @@ fun filterRelayGroupsByAuthors( } fun filterRelayGroupsByMutedAuthors( + cache: ICacheProvider, authorSet: MutedAuthorsTopNavPerRelayFilterSet, since: SincePerRelayMap?, defaultSince: Long? = null, ): List { if (authorSet.set.isEmpty()) return emptyList() - val channelsByRelay = relayGroupChannelsByRelay() + val channelsByRelay = relayGroupChannelsByRelay(cache) return authorSet.set.flatMap { filterRelayGroupsByAuthors( relay = it.key, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByCommunity.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByCommunity.kt index 3740c837a6..46c11cb351 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByFollows.kt similarity index 92% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByFollows.kt index 2f060c6e43..60eb06668f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByFollows.kt @@ -18,8 +18,9 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @@ -29,13 +30,14 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter // AnyOf constraint matches all three lenses, so the REQ must fetch all three — otherwise a group // under a followed hashtag run by non-followed people would be matched but never requested. fun filterRelayGroupsByFollows( + cache: ICacheProvider, followsSet: AllFollowsTopNavPerRelayFilterSet, since: SincePerRelayMap?, defaultSince: Long? = null, ): List { if (followsSet.set.isEmpty()) return emptyList() - val channelsByRelay = relayGroupChannelsByRelay() + val channelsByRelay = relayGroupChannelsByRelay(cache) return followsSet.set.flatMap { val relay = it.key val relaySince = since?.get(relay)?.time ?: defaultSince diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByGeohashes.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByGeohashes.kt index 6f04f42003..ba7b432d15 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByHashtag.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByHashtag.kt index d5b5b105fe..15bf57e780 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByRelay.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByRelay.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByRelay.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByRelay.kt index 228a868da9..4586ac2921 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByRelay.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByRelay.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.model.topNavFeeds.relay.RelayTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsDirectory.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsDirectory.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsDirectory.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsDirectory.kt index 06595c754b..3ad1124185 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsDirectory.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsDirectory.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsGlobal.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsGlobal.kt index a467d3a22e..fc87c5d6a3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupFilterBuilders.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuilders.kt similarity index 99% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupFilterBuilders.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuilders.kt index d432e55357..479bceb294 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupFilterBuilders.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuilders.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessFeedFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/ChessFeedFilterSubAssembler.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessFeedFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/ChessFeedFilterSubAssembler.kt index 438c600977..601ca985ef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessFeedFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/ChessFeedFilterSubAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chess.datasource +package com.vitorpamplona.amethyst.commons.relayClient.chess import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/ChessFilterAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/ChessFilterAssembler.kt index a083cbf0d7..34d79dcf64 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/ChessFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/ChessFilterAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chess.datasource +package com.vitorpamplona.amethyst.commons.relayClient.chess import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.core.Event diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/FilterChessEvent.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/FilterChessEvent.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/FilterChessEvent.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/FilterChessEvent.kt index 58c7619718..098d161e24 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/datasource/FilterChessEvent.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/chess/FilterChessEvent.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chess.datasource +package com.vitorpamplona.amethyst.commons.relayClient.chess import com.vitorpamplona.amethyst.commons.nip64Chess.subscription.ChessFilterBuilder import com.vitorpamplona.amethyst.commons.nip64Chess.subscription.ChessSubscriptionState diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFeedFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFeedFilterSubAssembler.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFeedFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFeedFilterSubAssembler.kt index fa88d8d4de..f3827f990f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFeedFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFeedFilterSubAssembler.kt @@ -18,17 +18,18 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource +package com.vitorpamplona.amethyst.commons.relayClient.communities +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.SingleSubEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.utils.mapOfSet class CommunityFeedFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : SingleSubEoseManager(client, allKeys) { @@ -44,7 +45,7 @@ class CommunityFeedFilterSubAssembler( val communityRelays = ( commEvent.relayUrls().ifEmpty { - LocalCache.relayHints.hintsForAddress(commEvent.addressTag()) + cache.relayHints.hintsForAddress(commEvent.addressTag()) } + it.community.relayUrls() ).toSet() @@ -52,7 +53,7 @@ class CommunityFeedFilterSubAssembler( mapOfSet { commEvent.moderatorKeys().forEach { modKey -> // hits the relay of each moderator for approvals - LocalCache.checkGetOrCreateUser(modKey)?.outboxRelays()?.forEach { relay -> + cache.checkGetOrCreateUser(modKey)?.outboxRelays()?.forEach { relay -> add(relay, modKey) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFilterAssembler.kt similarity index 85% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFilterAssembler.kt index b199d999d5..e3351bfc52 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFilterAssembler.kt @@ -18,9 +18,10 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource +package com.vitorpamplona.amethyst.commons.relayClient.communities import com.vitorpamplona.amethyst.commons.model.AddressableNote +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient @@ -30,12 +31,13 @@ class CommunityQueryState( ) class CommunityFilterAssembler( + cache: ICacheProvider, client: INostrClient, ) : ComposeSubscriptionManager() { val group = listOf( - CommunityFeedFilterSubAssembler(client, ::allKeys), - CommunityRulesFilterSubAssembler(client, ::allKeys), + CommunityFeedFilterSubAssembler(cache, client, ::allKeys), + CommunityRulesFilterSubAssembler(cache, client, ::allKeys), ) override fun invalidateKeys() = invalidateFilters() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFilterAssemblerSubscription.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFilterAssemblerSubscription.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFilterAssemblerSubscription.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFilterAssemblerSubscription.kt index 3976bc6fb6..b52de16a7b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityFilterAssemblerSubscription.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityFilterAssemblerSubscription.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource +package com.vitorpamplona.amethyst.commons.relayClient.communities import androidx.compose.runtime.Composable import androidx.compose.runtime.remember diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityRulesFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityRulesFilterSubAssembler.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityRulesFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityRulesFilterSubAssembler.kt index d0c2c0f9da..9b4d4035b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/CommunityRulesFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/CommunityRulesFilterSubAssembler.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource +package com.vitorpamplona.amethyst.commons.relayClient.communities +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.SingleSubEoseManager import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent @@ -40,6 +40,7 @@ import com.vitorpamplona.quartz.nip72ModCommunities.rules.CommunityRulesEvent * declared moderator are accepted, matching the trust model of NIP-72 approvals. */ class CommunityRulesFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : SingleSubEoseManager(client, allKeys) { @@ -57,7 +58,7 @@ class CommunityRulesFilterSubAssembler( val communityRelays = ( commEvent.relayUrls().ifEmpty { - LocalCache.relayHints.hintsForAddress(commEvent.addressTag()) + cache.relayHints.hintsForAddress(commEvent.addressTag()) } + key.community.relayUrls() ).toSet() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/FilterCommunityPosts.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/FilterCommunityPosts.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/FilterCommunityPosts.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/FilterCommunityPosts.kt index 143da7c09a..ef795c5880 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/FilterCommunityPosts.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/FilterCommunityPosts.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.datasource +package com.vitorpamplona.amethyst.commons.relayClient.communities import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/list/CommunitiesListFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/list/CommunitiesListFilterAssembler.kt index e5cfa306fd..dc0f353767 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/list/datasource/CommunitiesListFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/list/CommunitiesListFilterAssembler.kt @@ -18,34 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.communities.list.datasource +package com.vitorpamplona.amethyst.commons.relayClient.communities.list -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.makeCommunitiesFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class CommunitiesListQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class CommunitiesListFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - CommunitiesListSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeCommunitiesFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryFilterAssembler.kt similarity index 51% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryFilterAssembler.kt index 5aedd3220a..959d71ce03 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryFilterAssembler.kt @@ -18,35 +18,48 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource +package com.vitorpamplona.amethyst.commons.relayClient.discover -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.model.IAccount +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState +import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.StateFlow -// This allows multiple screen to be listening to tags, even the same tag +/** + * Key for the Discover screen: one top-nav selection shared by its seven tabs, each with its own + * feed floor. The three sub-assemblers each bound their REQs by the floors of the tabs they serve. + */ class DiscoveryQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery + account: IAccount, + listName: StateFlow, + followsPerRelay: StateFlow, + scope: CoroutineScope, + val reads: FeedContentState, + val marketplace: FeedContentState, + val dvms: FeedContentState, + val followSets: FeedContentState, + val live: FeedContentState, + val publicChats: FeedContentState, + val communities: FeedContentState, +) : TopNavFeedQueryState( + account, + listName, + followsPerRelay, + scope, + listOf(reads, marketplace, dvms, followSets, live, publicChats, communities), + ) class DiscoveryFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = +) : TopNavFeedFilterAssembler({ keys -> listOf( - DiscoveryLongFormClassifiedsAndDVMSubAssembler1(client, ::allKeys), - DiscoveryFollowsSetsAndLiveStreamsSubAssembler2(client, ::allKeys), - DiscoveryPublicChatsAndCommunitiesSubAssembler3(client, ::allKeys), + DiscoveryLongFormClassifiedsAndDVMSubAssembler1(client, keys), + DiscoveryFollowsSetsAndLiveStreamsSubAssembler2(client, keys), + DiscoveryPublicChatsAndCommunitiesSubAssembler3(client, keys), ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} + }) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt new file mode 100644 index 0000000000..f170921236 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.discover + +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.makeFollowSetsFilter +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.makeLiveActivitiesFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient +import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter +import kotlinx.coroutines.flow.StateFlow + +class DiscoveryFollowsSetsAndLiveStreamsSubAssembler2( + client: INostrClient, + allKeys: () -> Set, +) : TopNavFeedSubAssembler(client, allKeys) { + override fun updateFilter( + key: DiscoveryQueryState, + since: SincePerRelayMap?, + ): List { + val feedSettings = key.followsPerRelay.value + return makeFollowSetsFilter(feedSettings, since, key.followSets.lastNoteCreatedAtIfFilled()) + + makeLiveActivitiesFilter(feedSettings, since, key.live.lastNoteCreatedAtIfFilled()) + } + + override fun floors(key: DiscoveryQueryState): List> = listOf(key.followSets, key.live).map { it.lastNoteCreatedAtWhenFullyLoaded } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt new file mode 100644 index 0000000000..b18ec78875 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.discover + +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.makeLongFormFilter +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.makeContentDVMsFilter +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.makeClassifiedsFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient +import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter +import kotlinx.coroutines.flow.StateFlow + +class DiscoveryLongFormClassifiedsAndDVMSubAssembler1( + client: INostrClient, + allKeys: () -> Set, +) : TopNavFeedSubAssembler(client, allKeys) { + override fun updateFilter( + key: DiscoveryQueryState, + since: SincePerRelayMap?, + ): List { + val feedSettings = key.followsPerRelay.value + return makeLongFormFilter(feedSettings, since, key.reads.lastNoteCreatedAtIfFilled()) + + makeClassifiedsFilter(feedSettings, since, key.marketplace.lastNoteCreatedAtIfFilled()) + + makeContentDVMsFilter(feedSettings, since, key.dvms.lastNoteCreatedAtIfFilled()) + } + + override fun floors(key: DiscoveryQueryState): List> = listOf(key.reads, key.marketplace, key.dvms).map { it.lastNoteCreatedAtWhenFullyLoaded } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt new file mode 100644 index 0000000000..ca0183ebc8 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.discover + +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.makePublicChatsFilter +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.makeCommunitiesFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient +import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter +import kotlinx.coroutines.flow.StateFlow + +class DiscoveryPublicChatsAndCommunitiesSubAssembler3( + client: INostrClient, + allKeys: () -> Set, +) : TopNavFeedSubAssembler(client, allKeys) { + override fun updateFilter( + key: DiscoveryQueryState, + since: SincePerRelayMap?, + ): List { + val feedSettings = key.followsPerRelay.value + return makePublicChatsFilter(feedSettings, since, key.publicChats.lastNoteCreatedAtIfFilled()) + + makeCommunitiesFilter(feedSettings, since, key.communities.lastNoteCreatedAtIfFilled()) + } + + override fun floors(key: DiscoveryQueryState): List> = listOf(key.publicChats, key.communities).map { it.lastNoteCreatedAtWhenFullyLoaded } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAllCommunities.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAllCommunities.kt index a2d95e0921..ff5958375f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAuthors.kt index 5a9fcaee7b..e9b4eab6ae 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByCommunity.kt index 1aa4c75289..a93b476ab0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByFollows.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByFollows.kt index ec65327e18..b20d619163 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByGeohash.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByGeohash.kt index 143d05ae25..cd35d75baa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByGeohash.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesByGeohash import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesByGeohash import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByHashtag.kt index 0e343725ad..e857cd1b62 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormGlobal.kt index a88f1d87f2..67b266a7ab 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/SubAssemblyHelper.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/SubAssemblyHelper.kt index 331eb2f8b4..285c6a5cf1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,15 +29,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.filterLongFormByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.filterLongFormByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.filterLongFormByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.filterLongFormByFollows +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.filterLongFormByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.filterLongFormByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip23LongForm.filterLongFormGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies.filterLongFormByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies.filterLongFormByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies.filterLongFormByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies.filterLongFormByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies.filterLongFormByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies.filterLongFormByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.subassemblies.filterLongFormGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeLongFormFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByAllCommunities.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByAllCommunities.kt index af8882e16a..14e1d37652 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByAuthors.kt index 85f6c20250..5dae8cc199 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByCommunity.kt index d9cb07d4ec..9de9613598 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByFollows.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByFollows.kt index abe5e8773d..f13b0dff6f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByGeohash.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByGeohash.kt index d8ea1409c8..b4422e2b5e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByGeohash.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByHashtag.kt index 54aa100e33..2ee8216511 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsGlobal.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsGlobal.kt index 50e85028fc..67d641a83f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/FilterPublicChatsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/SubAssemblyHelper.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/SubAssemblyHelper.kt index f1409ad47f..c700e1a310 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip28Chats/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,15 +29,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.filterPublicChatsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.filterPublicChatsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.filterPublicChatsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.filterPublicChatsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.filterPublicChatsByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.filterPublicChatsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.filterPublicChatsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies.filterPublicChatsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies.filterPublicChatsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies.filterPublicChatsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies.filterPublicChatsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies.filterPublicChatsByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies.filterPublicChatsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip28Chats.subassemblies.filterPublicChatsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makePublicChatsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt index fc91a026a1..b59a5bec9c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsAllCommunities import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsAllCommunities import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt index e3a0c7527f..0fc3c986d5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt index 63d038b355..095ab751ed 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByFollows.kt index c67f2e9d76..e49f21c25a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt index 2817d336e2..f671ba36b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt index 7fee5c0441..bc53534f50 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt index 1e812cd39b..a853b22722 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/SubAssemblyHelper.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/SubAssemblyHelper.kt index bb89b336e9..221bf211c0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,15 +29,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.filterFollowSetsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.filterFollowSetsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.filterFollowSetsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.filterFollowSetsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.filterFollowSetsByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.filterFollowSetsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.filterFollowSetsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies.filterFollowSetsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies.filterFollowSetsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies.filterFollowSetsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies.filterFollowSetsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies.filterFollowSetsByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies.filterFollowSetsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.subassemblies.filterFollowSetsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeFollowSetsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByAllCommunities.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByAllCommunities.kt index e773828638..319b16d3c7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByAuthors.kt index 67ae6a60e8..caf3aa9cd1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByCommunity.kt index 07737a5ed1..6ce9041088 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByFollows.kt index b576aa0f2c..f942fe7650 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByGeohash.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByGeohash.kt index f4074c4322..671c9ada73 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByGeohash.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByHashtag.kt index a80c2dbd79..f91c82b4f3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesGlobal.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesGlobal.kt index d3b31ff75f..813cc1304c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/FilterLiveActivitiesGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/SubAssemblyHelper.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/SubAssemblyHelper.kt index 1545ff5ded..b6aba8c084 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip53LiveActivities/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,15 +29,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesByFollows +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.filterLiveActivitiesGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivities.subassemblies.filterLiveActivitiesGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeLiveActivitiesFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByAllCommunities.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByAllCommunities.kt index 4025a163ba..e82e955814 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByAuthors.kt index 15ee0105c3..c1f9a0f34b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByCommunity.kt index 31aff9df38..911a1ab7e1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByFollows.kt index ed26b4ba7a..0941f70ced 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByGeohash.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByGeohash.kt index 8cbc10d81d..d9168145bb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByGeohash.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByHashtag.kt index d5acef5793..5eb5903f33 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesGlobal.kt index 537f19174f..46b700c11e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/FilterCommunitiesGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/SubAssemblyHelper.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/SubAssemblyHelper.kt index 5f18fb9092..dce34fd195 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip72Communities/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,15 +29,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.filterCommunitiesByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.filterCommunitiesByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.filterCommunitiesByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.filterCommunitiesByFollows +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.filterCommunitiesByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.filterCommunitiesByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip72Communities.filterCommunitiesGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies.filterCommunitiesByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies.filterCommunitiesByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies.filterCommunitiesByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies.filterCommunitiesByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies.filterCommunitiesByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies.filterCommunitiesByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.subassemblies.filterCommunitiesGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeCommunitiesFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByAllCommunities.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByAllCommunities.kt index 055a870b29..21a4464a96 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByAuthors.kt index 5cc6016565..ae8e2e5fd5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByCommunity.kt index 4a001ca526..d43eb719b1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByFollows.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByFollows.kt index 8662a03c8d..deb1662cbe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByGeohash.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByGeohash.kt index fa3bbe3860..5dcfcc21a2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByGeohash.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByHashtag.kt index 6d536e2fac..669320e1e1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsGlobal.kt index 0526255d02..b0abff4a45 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/FilterContentDVMsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/SubAssemblyHelper.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/SubAssemblyHelper.kt index f36a058f9b..ba96a3b35d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip90DVMs/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,15 +29,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip90DVMs.filterContentDVMsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.subassemblies.filterContentDVMsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeContentDVMsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByAllCommunities.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByAllCommunities.kt index c97860487a..38e7769c00 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByAuthors.kt index e138495fe7..fcc5546b8a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByCommunity.kt index cd7ec5f674..6d68f38a98 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByFollows.kt index b9114d833f..aa709ff93b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByGeohash.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByGeohash.kt index edab4df39a..2142b05e49 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByGeohash.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByHashtag.kt index 99d0966804..933e76b575 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsGlobal.kt index eb8fa12f3f..bee701c1de 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/FilterClassifiedsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/SubAssemblyHelper.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/SubAssemblyHelper.kt index 03f09de725..846e5f8cb9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip99Classifieds/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds +package com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,15 +29,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.filterClassifiedsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.filterClassifiedsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.filterClassifiedsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.filterClassifiedsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.filterClassifiedsByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.filterClassifiedsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.filterClassifiedsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies.filterClassifiedsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies.filterClassifiedsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies.filterClassifiedsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies.filterClassifiedsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies.filterClassifiedsByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies.filterClassifiedsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.subassemblies.filterClassifiedsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeClassifiedsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/BrowseEmojiSetsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/BrowseEmojiSetsFilterAssembler.kt index 1723e7e32d..30e8dec95c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/BrowseEmojiSetsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/BrowseEmojiSetsFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource +package com.vitorpamplona.amethyst.commons.relayClient.emojipacks -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class BrowseEmojiSetsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class BrowseEmojiSetsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - BrowseEmojiSetsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeBrowseEmojiSetsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByAuthors.kt index 1caebcd271..6328954f56 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.emojipacks import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByFollows.kt index de8119006e..d3fc1fb357 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.emojipacks import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByHashtag.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByHashtag.kt index 694c906704..4b7e7ea2d8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.emojipacks import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsGlobal.kt index 1284811dbe..675b22d9e1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/subassemblies/FilterBrowseEmojiSetsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/FilterBrowseEmojiSetsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.emojipacks import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/SubAssemblyHelper.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/SubAssemblyHelper.kt index c8d120629e..e7a777773d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/emojipacks/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource +package com.vitorpamplona.amethyst.commons.relayClient.emojipacks import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -26,13 +26,13 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavP import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.emojipacks.filterBrowseEmojiSetsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.emojipacks.filterBrowseEmojiSetsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.emojipacks.filterBrowseEmojiSetsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.emojipacks.filterBrowseEmojiSetsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.emojipacks.filterBrowseEmojiSetsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies.filterBrowseEmojiSetsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies.filterBrowseEmojiSetsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies.filterBrowseEmojiSetsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies.filterBrowseEmojiSetsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.emojipacks.browse.datasource.subassemblies.filterBrowseEmojiSetsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeBrowseEmojiSetsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/followPacks/FollowPacksFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/followPacks/FollowPacksFilterAssembler.kt index 3f78c6974e..1261ffd92f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/datasource/FollowPacksFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/followPacks/FollowPacksFilterAssembler.kt @@ -18,34 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.list.datasource +package com.vitorpamplona.amethyst.commons.relayClient.followPacks -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip51FollowSets.makeFollowSetsFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class FollowPacksQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class FollowPacksFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - FollowPacksSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeFollowSetsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/FilterPostsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/FilterPostsByGeohash.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/FilterPostsByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/FilterPostsByGeohash.kt index e10214d9ac..f0cc4fb533 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/FilterPostsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/FilterPostsByGeohash.kt @@ -18,12 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.datasource +package com.vitorpamplona.amethyst.commons.relayClient.geohash +import com.vitorpamplona.amethyst.commons.relayClient.nip22Comments.CommentKinds import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments.CommentKinds import com.vitorpamplona.quartz.experimental.audio.header.AudioHeaderEvent import com.vitorpamplona.quartz.experimental.audio.track.AudioTrackEvent import com.vitorpamplona.quartz.experimental.music.playlist.MusicPlaylistEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFeedFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/GeoHashFeedFilterSubAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFeedFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/GeoHashFeedFilterSubAssembler.kt index 695edc79e6..ab87c2d5f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFeedFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/GeoHashFeedFilterSubAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.datasource +package com.vitorpamplona.amethyst.commons.relayClient.geohash import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/GeoHashFilterAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/GeoHashFilterAssembler.kt index af5257fa67..109007624c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/datasource/GeoHashFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/GeoHashFilterAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.datasource +package com.vitorpamplona.amethyst.commons.relayClient.geohash import androidx.compose.runtime.Stable import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/FilterRepositoryContent.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/FilterRepositoryContent.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/FilterRepositoryContent.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/FilterRepositoryContent.kt index 924f9dbf96..560c5c6b0f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/FilterRepositoryContent.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/FilterRepositoryContent.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.datasource +package com.vitorpamplona.amethyst.commons.relayClient.gitRepo import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryContentSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryContentSubAssembler.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryContentSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryContentSubAssembler.kt index 66209a774d..54bb2d9f7e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryContentSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryContentSubAssembler.kt @@ -18,17 +18,18 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.datasource +package com.vitorpamplona.amethyst.commons.relayClient.gitRepo +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.SingleSubEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent class RepositoryContentSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : SingleSubEoseManager(client, allKeys) { @@ -44,7 +45,7 @@ class RepositoryContentSubAssembler( val announcedRelays = repoEvent.relays().mapNotNull(RelayUrlNormalizer::normalizeOrNull) val hintRelays = if (announcedRelays.isEmpty()) { - LocalCache.relayHints.hintsForAddress(repoEvent.addressTag()) + cache.relayHints.hintsForAddress(repoEvent.addressTag()) } else { emptyList() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryFilterAssembler.kt similarity index 88% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryFilterAssembler.kt index 6878ac2561..8f6b998c8f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryFilterAssembler.kt @@ -18,9 +18,10 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.datasource +package com.vitorpamplona.amethyst.commons.relayClient.gitRepo import com.vitorpamplona.amethyst.commons.model.AddressableNote +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient @@ -29,11 +30,12 @@ class RepositoryQueryState( ) class RepositoryFilterAssembler( + cache: ICacheProvider, client: INostrClient, ) : ComposeSubscriptionManager() { val group = listOf( - RepositoryContentSubAssembler(client, ::allKeys), + RepositoryContentSubAssembler(cache, client, ::allKeys), ) override fun invalidateKeys() = invalidateFilters() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryFilterAssemblerSubscription.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryFilterAssemblerSubscription.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryFilterAssemblerSubscription.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryFilterAssemblerSubscription.kt index 6ab0bc791f..a0855fc9ee 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/datasource/RepositoryFilterAssemblerSubscription.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepo/RepositoryFilterAssemblerSubscription.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepo.datasource +package com.vitorpamplona.amethyst.commons.relayClient.gitRepo import androidx.compose.runtime.Composable import androidx.compose.runtime.remember diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByAllCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByAllCommunities.kt index 2cb0af9c9d..4b557bfa2f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByAuthors.kt index d584b1d7ac..51bc0d79cd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByFollows.kt index 87776f277d..3d77940ee1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByGeohashes.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByGeohashes.kt index 44b9b27da2..fc8ca2cc5a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByHashtag.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByHashtag.kt index a970d59fc3..6c63b95e31 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesGlobal.kt index 059d27999d..2391eab02d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/subassemblies/FilterGitRepositoriesGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/FilterGitRepositoriesGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilter.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/GitRepositoriesFilter.kt similarity index 76% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilter.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/GitRepositoriesFilter.kt index 232627861d..b4cfd0ab6d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilter.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/GitRepositoriesFilter.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,16 +29,16 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesByFollows +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.gitRepositories.filterGitRepositoriesGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource.subassemblies.filterGitRepositoriesGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeGitRepositoriesFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/GitRepositoriesFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/GitRepositoriesFilterAssembler.kt index 7dfda65ee9..93a8e44afa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepositories/datasource/GitRepositoriesFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/gitRepositories/GitRepositoriesFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.gitRepositories.datasource +package com.vitorpamplona.amethyst.commons.relayClient.gitRepositories -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class GitRepositoriesQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class GitRepositoriesFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - GitRepositoriesSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeGitRepositoriesFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByAuthors.kt index 797105556b..8ffb9f1a70 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.highlights import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByFollows.kt index b6e236f3b1..9783d804aa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.highlights import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByGeohashes.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByGeohashes.kt index 3f0c5badaf..0c90d0efeb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.highlights import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByHashtag.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByHashtag.kt index ea94e5aa02..2297a5b9af 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.highlights import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsGlobal.kt index f21f43ec97..0a9ee975c5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/subassemblies/FilterHighlightsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/FilterHighlightsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.highlights import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilter.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/HighlightsFilter.kt similarity index 81% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilter.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/HighlightsFilter.kt index 8d96b1d53f..3ca6293dbc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilter.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/HighlightsFilter.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource +package com.vitorpamplona.amethyst.commons.relayClient.highlights import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -27,14 +27,14 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavP import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.highlights.filterHighlightsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.highlights.filterHighlightsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.highlights.filterHighlightsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.highlights.filterHighlightsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.highlights.filterHighlightsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.highlights.filterHighlightsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies.filterHighlightsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies.filterHighlightsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies.filterHighlightsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies.filterHighlightsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies.filterHighlightsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource.subassemblies.filterHighlightsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/HighlightsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/HighlightsFilterAssembler.kt index b824c18903..71184a197f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/highlights/datasource/HighlightsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/highlights/HighlightsFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.highlights.datasource +package com.vitorpamplona.amethyst.commons.relayClient.highlights -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class HighlightsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class HighlightsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - HighlightsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeHighlightsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/livestreams/LiveStreamsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/livestreams/LiveStreamsFilterAssembler.kt index 73c71d760d..1185f15bef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/datasource/LiveStreamsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/livestreams/LiveStreamsFilterAssembler.kt @@ -18,34 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.livestreams.datasource +package com.vitorpamplona.amethyst.commons.relayClient.livestreams -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip53LiveActivities.makeLiveActivitiesFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class LiveStreamsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class LiveStreamsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - LiveStreamsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeLiveActivitiesFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAllCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAllCommunities.kt index 6f0bd828cd..c8b32bae95 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.longs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAuthors.kt index cdb9238fcc..2c365f4fbd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.longs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByFollows.kt index a4905eff8b..8252e2ff5a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.longs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByGeohashes.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByGeohashes.kt index 6a50580897..8cf5096e02 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.longs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByHashtag.kt index 04a55be44d..85e2eee01b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.longs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsGlobal.kt index 30a21e9312..c538f86362 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/subassemblies/FilterLongsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.longs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/LongsFilterAssembler.kt similarity index 56% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/LongsFilterAssembler.kt index 93a221074d..99f7b36abb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/LongsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/LongsFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource +package com.vitorpamplona.amethyst.commons.relayClient.longs -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class LongsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class LongsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - LongsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeLongsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/SubAssemblyHelper.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/SubAssemblyHelper.kt index 34fdb128d5..d730bd4247 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource +package com.vitorpamplona.amethyst.commons.relayClient.longs import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,16 +29,16 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.longs.filterLongsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.longs.datasource.subassemblies.filterLongsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeLongsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByAuthors.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByAuthors.kt index c5fa616e58..afbabac9a8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.music import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByCommunities.kt index 2fa51d258c..f6cc07140e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.music import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByFollows.kt index d599f048f8..fad8fbe261 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.music import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByGeohashes.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByGeohashes.kt index abafadc299..67c2d70265 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.music import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByHashtag.kt index 1c07a49d44..e4603265c4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.music import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsGlobal.kt index 389720d48c..293fd3b4db 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/subassemblies/FilterMusicEventsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/FilterMusicEventsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.music import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/MusicPlaylistsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/MusicPlaylistsFilterAssembler.kt index ad87b5551a..17698c3521 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicPlaylistsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/MusicPlaylistsFilterAssembler.kt @@ -18,34 +18,19 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource +package com.vitorpamplona.amethyst.commons.relayClient.music -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class MusicPlaylistsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable +/** + * Keyed on the user's *playlists* follow list, not the tracks one: the playlists screen has its own + * top-bar spinner, and reusing the tracks subscription left the playlists feed empty whenever the + * two selections differed. Asks for kind 34139 only; tracks referenced by a playlist are loaded on + * demand by each playlist row's own per-track observer. + */ class MusicPlaylistsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - MusicPlaylistsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeMusicPlaylistsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/MusicTracksFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/MusicTracksFilterAssembler.kt index 6a33c68708..19eead807b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/MusicTracksFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/MusicTracksFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource +package com.vitorpamplona.amethyst.commons.relayClient.music -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class MusicTracksQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class MusicTracksFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - MusicTracksSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeMusicTracksFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/SubAssemblyHelper.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/SubAssemblyHelper.kt index 1122b22556..8ee87b90af 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/music/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/music/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource +package com.vitorpamplona.amethyst.commons.relayClient.music import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,18 +29,18 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.music.MUSIC_PLAYLIST_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.music.MUSIC_TRACK_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.music.filterMusicEventsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.MUSIC_PLAYLIST_KINDS -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.MUSIC_TRACK_KINDS -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.music.datasource.subassemblies.filterMusicEventsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsByAuthors.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsByAuthors.kt index 2269deacf9..fa0ea5512e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsByAuthors.kt @@ -18,14 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.napplets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.NAPPLET_PAGE_LIMIT import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsByFollows.kt index a3c566e693..6ae83c3fce 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.napplets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsGlobal.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsGlobal.kt index c8375ccfe2..1d27b39e63 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/subassemblies/FilterNappletsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/FilterNappletsGlobal.kt @@ -18,13 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.napplets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.NAPPLET_PAGE_LIMIT import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip5dNapplets.NamedNappletEvent import com.vitorpamplona.quartz.nip5dNapplets.RootNappletEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/NappletsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/NappletsFilterAssembler.kt new file mode 100644 index 0000000000..40127de842 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/NappletsFilterAssembler.kt @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.napplets + +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient + +/** + * Subscribes to NIP-5D napplet manifests (kinds 15129/35129) while a napplet screen is open, + * honoring the top-nav follow-list selection at the relay level (authors resolved to their outbox + * relays) and dumping the results into the cache for the screen to observe. The key carries no + * feed: the screen reads the manifests straight out of the cache. The only spinner options are + * author-based, so [makeNappletsFilter] needs no tag-based branches. + */ +class NappletsFilterAssembler( + client: INostrClient, +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeNappletsFilter)) }) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/NappletsPageLimit.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/NappletsPageLimit.kt new file mode 100644 index 0000000000..794aab2a57 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/NappletsPageLimit.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.napplets + +/** How many nApplet manifests (NIP-5D) to pull per relay for the browse screen. */ +const val NAPPLET_PAGE_LIMIT = 200 diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/SubAssemblyHelper.kt similarity index 84% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/SubAssemblyHelper.kt index 8ef77f1cd9..6d76b6fca2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/napplets/SubAssemblyHelper.kt @@ -18,23 +18,21 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource +package com.vitorpamplona.amethyst.commons.relayClient.napplets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.napplets.filterNappletsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.napplets.filterNappletsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.napplets.filterNappletsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.napplets.filterNappletsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies.filterNappletsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies.filterNappletsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies.filterNappletsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.napplets.datasource.subassemblies.filterNappletsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -const val NAPPLET_PAGE_LIMIT = 200 - /** * Maps the top-nav selection (already resolved to a per-relay filter set) to the relay REQs for the * nApplet browse screen. nApplet manifests (NIP-5D, kinds 15129/35129) carry no topical tags, so only diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByAllCommunities.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByAllCommunities.kt index 353e33d53a..345e5ca645 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByAuthors.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByAuthors.kt index b661479e68..fd8e37199c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByCommunity.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByCommunity.kt index 393f17a74f..e05675a753 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByCommunity.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByFollows.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByFollows.kt index e93ec1f582..6e46a0139e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByGeohash.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByGeohash.kt index 45eb28de05..2cc10b7873 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByGeohash.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByHashtag.kt index 187e6a43d6..9624e99309 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsGlobal.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsGlobal.kt index d6c472e7b9..44320ccdd6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/subassemblies/FilterNestsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/FilterNestsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/NestsFilterAssembler.kt similarity index 56% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/NestsFilterAssembler.kt index 5e25fe8437..fe78fe82ac 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/NestsFilterAssembler.kt @@ -18,34 +18,18 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource +package com.vitorpamplona.amethyst.commons.relayClient.nests -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class NestsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable +/** + * [makeNestsFilter] reuses the live-activities wire filter (kinds 30311/30312/30313/1311); the feed + * filter narrows to 30312/30313 client-side. Sharing the wire filter avoids duplicate REQs when + * both the Live Streams and Audio Rooms screens are open for the same user. + */ class NestsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - NestsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeNestsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/SubAssemblyHelper.kt similarity index 81% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/SubAssemblyHelper.kt index bf4d7037ea..2532a47809 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nests/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource +package com.vitorpamplona.amethyst.commons.relayClient.nests import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,16 +29,16 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsGlobal +import com.vitorpamplona.amethyst.commons.relayClient.nests.filterNestsPresence import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsByGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsGlobal -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.datasource.subassemblies.filterNestsPresence import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeNestsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip22Comments/FilterPostsByScopes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip22Comments/FilterPostsByScopes.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip22Comments/FilterPostsByScopes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip22Comments/FilterPostsByScopes.kt index d915ce741f..19bfd4b294 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip22Comments/FilterPostsByScopes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip22Comments/FilterPostsByScopes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments +package com.vitorpamplona.amethyst.commons.relayClient.nip22Comments import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesByAuthors.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesByAuthors.kt index 355af9b944..3e69752962 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesByAuthors.kt @@ -18,14 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nsites import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.NSITE_PAGE_LIMIT import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesByFollows.kt index 0064b92802..aad09415b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nsites import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesGlobal.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesGlobal.kt index e7a641d33a..44773d5b25 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/subassemblies/FilterNsitesGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/FilterNsitesGlobal.kt @@ -18,13 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.nsites import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.NSITE_PAGE_LIMIT import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.RootSiteEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/NsitesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/NsitesFilterAssembler.kt new file mode 100644 index 0000000000..305701ba8b --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/NsitesFilterAssembler.kt @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.nsites + +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient + +/** + * Subscribes to NIP-5A static-site manifests (kinds 15128/35128) while an nSite screen is open, + * honoring the top-nav follow-list selection at the relay level (authors resolved to their outbox + * relays) and dumping the results into the cache for the screen to observe. The key carries no + * feed: the screen reads the manifests straight out of the cache. The only spinner options are + * author-based, so [makeNsitesFilter] needs no tag-based branches. + */ +class NsitesFilterAssembler( + client: INostrClient, +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeNsitesFilter)) }) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/NsitesPageLimit.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/NsitesPageLimit.kt new file mode 100644 index 0000000000..0e54170c1b --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/NsitesPageLimit.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.nsites + +/** How many nSite manifests (NIP-5A) to pull per relay for the browse screen. */ +const val NSITE_PAGE_LIMIT = 200 diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/SubAssemblyHelper.kt similarity index 84% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/SubAssemblyHelper.kt index 34d854bb2a..18fab97247 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nsites/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nsites/SubAssemblyHelper.kt @@ -18,23 +18,21 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource +package com.vitorpamplona.amethyst.commons.relayClient.nsites import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.nsites.filterNsitesByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.nsites.filterNsitesByFollows +import com.vitorpamplona.amethyst.commons.relayClient.nsites.filterNsitesByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.nsites.filterNsitesGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.subassemblies.filterNsitesByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.subassemblies.filterNsitesByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.subassemblies.filterNsitesByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.nsites.datasource.subassemblies.filterNsitesGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -const val NSITE_PAGE_LIMIT = 200 - /** * Maps the top-nav selection (already resolved to a per-relay filter set) to the relay REQs for the * nSite browse screen. nSite manifests (NIP-5A, kinds 15128/35128) carry no topical tags, so only the diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByAllCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByAllCommunities.kt index b01e0f8a2e..1a13f9cb93 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.pictures import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByAuthors.kt index 0038a855f3..263315a4f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.pictures import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByFollows.kt index c7dcfd95d4..92456b2bf8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.pictures import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByGeohashes.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByGeohashes.kt index ebb4c4f037..e026043e88 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.pictures import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByHashtag.kt index cb5dc6f755..2ddf7f024c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.pictures import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesGlobal.kt index ad105bd3c2..b6ad165c95 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/subassemblies/FilterPicturesGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/FilterPicturesGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.pictures import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/PicturesFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/PicturesFilterAssembler.kt index eb8ab7112d..00672fe721 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/PicturesFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/PicturesFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource +package com.vitorpamplona.amethyst.commons.relayClient.pictures -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class PicturesQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class PicturesFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - PicturesSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makePicturesFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/SubAssemblyHelper.kt similarity index 77% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/SubAssemblyHelper.kt index 36e923dfed..448cb98881 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/pictures/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/pictures/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource +package com.vitorpamplona.amethyst.commons.relayClient.pictures import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,16 +29,16 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesByFollows +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.pictures.filterPicturesGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.pictures.datasource.subassemblies.filterPicturesGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makePicturesFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/FilterMyPodcast.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterMyPodcast.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/FilterMyPodcast.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterMyPodcast.kt index 719fef99da..0acdccef0c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/FilterMyPodcast.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterMyPodcast.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nipXXPodcasting20.episode.Podcasting20EpisodeEvent @@ -44,12 +44,13 @@ import com.vitorpamplona.quartz.nipXXPodcasting20.trailer.Podcasting20TrailerEve * filter, since each episode/trailer carries its own `d` tag — a combined `#d` would match nothing. */ fun filterMyPodcast( + cache: ICacheProvider, user: User, since: SincePerRelayMap?, ): List { val relays = user.outboxRelays()?.ifEmpty { null } - ?: (user.allUsedRelays() + LocalCache.relayHints.hintsForKey(user.pubkeyHex)) + ?: (user.allUsedRelays() + cache.relayHints.hintsForKey(user.pubkeyHex)) val authors = listOf(user.pubkeyHex) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/FilterOnePodcast.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterOnePodcast.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/FilterOnePodcast.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterOnePodcast.kt index 9d8417578b..8dd726ce71 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/FilterOnePodcast.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterOnePodcast.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nipF4Podcasts.episode.PodcastEpisodeEvent @@ -45,6 +45,7 @@ private val OnePodcastKinds = ) fun filterOnePodcast( + cache: ICacheProvider, user: User, since: SincePerRelayMap?, ): List { @@ -52,7 +53,7 @@ fun filterOnePodcast( // we've seen the key on plus stored hints when no NIP-65 list is known. val relays = user.outboxRelays()?.ifEmpty { null } - ?: (user.allUsedRelays() + LocalCache.relayHints.hintsForKey(user.pubkeyHex)) + ?: (user.allUsedRelays() + cache.relayHints.hintsForKey(user.pubkeyHex)) return relays.flatMap { relay -> listOf( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByAuthors.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByAuthors.kt index 572d617c29..3d2d64edf6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByCommunities.kt index 8789b94e2a..ebe8c6d023 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByFollows.kt index 819cdb4ebf..cf6871535b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByGeohashes.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByGeohashes.kt index 4e1b310b3b..92bc6aa231 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByHashtag.kt index c6eda6765f..940e63fcb1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsGlobal.kt index 5e69347329..4c4b056644 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/FilterPodcastEventsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/FilterPodcastEventsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFeedSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MyPodcastFeedSubAssembler.kt similarity index 88% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFeedSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MyPodcastFeedSubAssembler.kt index 46ec1613ed..74de208be2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFeedSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MyPodcastFeedSubAssembler.kt @@ -18,21 +18,23 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter class MyPodcastFeedSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUserEoseManager(client, allKeys) { override fun updateFilter( key: MyPodcastQueryState, since: SincePerRelayMap?, - ): List = filterMyPodcast(user(key), since) + ): List = filterMyPodcast(cache, user(key), since) override fun user(key: MyPodcastQueryState) = key.user } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MyPodcastFilterAssembler.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MyPodcastFilterAssembler.kt index 0d6f8313e2..cba212b3db 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/MyPodcastFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MyPodcastFilterAssembler.kt @@ -18,9 +18,10 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient @@ -31,11 +32,12 @@ class MyPodcastQueryState( ) class MyPodcastFilterAssembler( + cache: ICacheProvider, client: INostrClient, ) : ComposeSubscriptionManager() { val group = listOf( - MyPodcastFeedSubAssembler(client, ::allKeys), + MyPodcastFeedSubAssembler(cache, client, ::allKeys), ) override fun invalidateKeys() = invalidateFilters() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFeedSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/OnePodcastFeedSubAssembler.kt similarity index 88% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFeedSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/OnePodcastFeedSubAssembler.kt index ba1494f406..4f65c76302 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFeedSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/OnePodcastFeedSubAssembler.kt @@ -18,21 +18,23 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter class OnePodcastFeedSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUserEoseManager(client, allKeys) { override fun updateFilter( key: OnePodcastQueryState, since: SincePerRelayMap?, - ): List = filterOnePodcast(user(key), since) + ): List = filterOnePodcast(cache, user(key), since) override fun user(key: OnePodcastQueryState) = key.user } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/OnePodcastFilterAssembler.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/OnePodcastFilterAssembler.kt index adc95e3871..04801ead9c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/OnePodcastFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/OnePodcastFilterAssembler.kt @@ -18,9 +18,10 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient @@ -31,11 +32,12 @@ class OnePodcastQueryState( ) class OnePodcastFilterAssembler( + cache: ICacheProvider, client: INostrClient, ) : ComposeSubscriptionManager() { val group = listOf( - OnePodcastFeedSubAssembler(client, ::allKeys), + OnePodcastFeedSubAssembler(cache, client, ::allKeys), ) override fun invalidateKeys() = invalidateFilters() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/PodcastEpisodesFilterAssembler.kt similarity index 56% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/PodcastEpisodesFilterAssembler.kt index dddabca20b..07b6c4027c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastEpisodesFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/PodcastEpisodesFilterAssembler.kt @@ -18,31 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class PodcastEpisodesQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class PodcastEpisodesFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - private val episodes = PodcastEpisodesSubAssembler(client, ::allKeys) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = episodes.invalidateFilters() - - override fun destroy() = episodes.destroy() -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makePodcastEpisodesFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/PodcastsFilterAssembler.kt similarity index 57% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/PodcastsFilterAssembler.kt index 529a77f0b0..c6f3acd703 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/PodcastsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/PodcastsFilterAssembler.kt @@ -18,31 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class PodcastsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class PodcastsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - private val podcasts = PodcastsSubAssembler(client, ::allKeys) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = podcasts.invalidateFilters() - - override fun destroy() = podcasts.destroy() -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makePodcastsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/SubAssemblyHelper.kt similarity index 75% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/SubAssemblyHelper.kt index 986b1dc075..5b63d9a9b0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,20 +29,20 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PODCASTING20_METADATA_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PODCAST_EPISODE_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PODCAST_KINDS +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.PODCAST_METADATA_D_FILTER +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.podcasts.filterPodcastEventsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.PODCASTING20_METADATA_KINDS -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.PODCAST_EPISODE_KINDS -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.PODCAST_KINDS -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.PODCAST_METADATA_D_FILTER -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies.filterPodcastEventsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makePodcastEpisodesFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByAllCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByAllCommunities.kt index f0f5994cfd..0ebadd8ca6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.polls import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByAuthors.kt index 9736adf898..98204ce986 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.polls import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByFollows.kt index 2cbc9c9c34..97d74c14e4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.polls import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByGeohashes.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByGeohashes.kt index 9929ea295f..106a0bf3da 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.polls import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByHashtag.kt index 749dc41854..e6e2374f5d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.polls import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsGlobal.kt index 6fff280f82..e431f9e234 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/subassemblies/FilterPollsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/FilterPollsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.polls import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/PollsFilterAssembler.kt similarity index 56% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/PollsFilterAssembler.kt index 462134fcbe..196431778d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/PollsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/PollsFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource +package com.vitorpamplona.amethyst.commons.relayClient.polls -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class PollsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class PollsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - PollsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makePollsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/SubAssemblyHelper.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/SubAssemblyHelper.kt index 81f622474e..647e7476a1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource +package com.vitorpamplona.amethyst.commons.relayClient.polls import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,16 +29,16 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.polls.filterPollsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemblies.filterPollsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makePollsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/subassembies/FilterPollResponses.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/results/FilterPollResponses.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/subassembies/FilterPollResponses.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/results/FilterPollResponses.kt index ac3b934cb4..60343c0d38 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/subassembies/FilterPollResponses.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/results/FilterPollResponses.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.results.datasources.subassembies +package com.vitorpamplona.amethyst.commons.relayClient.polls.results import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/PollResponsesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/results/PollResponsesFilterAssembler.kt similarity index 88% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/PollResponsesFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/results/PollResponsesFilterAssembler.kt index 8e58dff8ea..fd34462d42 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/polls/results/datasources/PollResponsesFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/polls/results/PollResponsesFilterAssembler.kt @@ -18,16 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.results.datasources +package com.vitorpamplona.amethyst.commons.relayClient.polls.results import androidx.compose.runtime.Stable +import com.vitorpamplona.amethyst.commons.model.IAccount +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.model.LocalCache -import com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.results.datasources.subassembies.filterPollResponses import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @@ -36,7 +35,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @Stable class PollResponsesQueryState( val pollId: HexKey, - override val account: Account, + override val account: IAccount, ) : AccountScopedQuery /** @@ -51,9 +50,10 @@ class PollResponsesQueryState( */ @Stable class PollResponsesFilterAssembler( + cache: ICacheProvider, client: INostrClient, ) : ComposeSubscriptionManager() { - val group = listOf(PollResponsesSubAssembler(client, ::allKeys)) + val group = listOf(PollResponsesSubAssembler(cache, client, ::allKeys)) override fun invalidateKeys() = invalidateFilters() @@ -63,6 +63,7 @@ class PollResponsesFilterAssembler( } class PollResponsesSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUniqueIdEoseManager(client, allKeys) { @@ -72,7 +73,7 @@ class PollResponsesSubAssembler( ): List? { // The poll event carries the relays to ask; on a deep link it may still be in flight, in // which case there is nothing to ask yet and the filter re-assembles when it lands. - val poll = LocalCache.getNoteIfExists(key.pollId) ?: return null + val poll = cache.getNoteIfExists(key.pollId) ?: return null return filterPollResponses(poll, since) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/products/ProductsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/products/ProductsFilterAssembler.kt index d38f10aec5..6ea2efdff5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/products/datasource/ProductsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/products/ProductsFilterAssembler.kt @@ -18,34 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.products.datasource +package com.vitorpamplona.amethyst.commons.relayClient.products -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip99Classifieds.makeClassifiedsFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class ProductsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class ProductsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - ProductsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeClassifiedsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileFollowers.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileFollowers.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileFollowers.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileFollowers.kt index a627dd439a..e097c40cde 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileFollowers.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileFollowers.kt @@ -18,26 +18,27 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent val UserProfileFollowersKinds = listOf(ContactListEvent.KIND) fun filterUserProfileFollowers( + cache: ICacheProvider, user: User, since: SincePerRelayMap?, ): List { val relays = user.inboxRelays()?.ifEmpty { null } ?: user.allUsedRelaysOrNull() - ?: LocalCache.relayHints.hintsForKey(user.pubkeyHex) + ?: cache.relayHints.hintsForKey(user.pubkeyHex) return relays.map { RelayBasedFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLastSeen.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLastSeen.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLastSeen.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLastSeen.kt index d142d20157..acd38f719b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLastSeen.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLastSeen.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLists.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLists.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt index 2a8352ae0e..022f5cb712 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLists.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMedia.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMedia.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMedia.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMedia.kt index 5b689c1ca8..5d689fbb15 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMedia.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMedia.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.experimental.profileGallery.ProfileGalleryEntryEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent @@ -45,13 +45,14 @@ val UserProfileMediaKinds = ) fun filterUserProfileMedia( + cache: ICacheProvider, user: User, since: SincePerRelayMap?, ): List { val relays = user.outboxRelays()?.ifEmpty { null } ?: user.allUsedRelaysOrNull() - ?: LocalCache.relayHints.hintsForKey(user.pubkeyHex) + ?: cache.relayHints.hintsForKey(user.pubkeyHex) return relays.flatMap { relay -> listOf( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMetadata.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMetadata.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMetadata.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMetadata.kt index e36e500b5c..1718d8fa41 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMetadata.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMetadata.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfilePosts.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfilePosts.kt index b532d09058..90a178a102 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfilePosts.kt @@ -20,13 +20,13 @@ */ @file:Suppress("DEPRECATION") -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.experimental.attestations.attestation.AttestationEvent import com.vitorpamplona.quartz.experimental.birdstar.BirdDetectionEvent import com.vitorpamplona.quartz.experimental.birdstar.BirdexEvent @@ -92,12 +92,13 @@ val UserProfileAppKinds = ) fun filterUserProfilePosts( + cache: ICacheProvider, user: User, since: SincePerRelayMap?, ): List { val relays = user.outboxRelays()?.ifEmpty { null } - ?: (user.allUsedRelays() + LocalCache.relayHints.hintsForKey(user.pubkeyHex)) + ?: (user.allUsedRelays() + cache.relayHints.hintsForKey(user.pubkeyHex)) return relays.flatMap { relay -> listOf( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileZapReceived.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileZapReceived.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileZapReceived.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileZapReceived.kt index dbd174f465..8d5ab4790b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileZapReceived.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileZapReceived.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent @@ -33,13 +33,14 @@ import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent val UserProfileZapReceiverKinds = listOf(LnZapEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND) fun filterUserProfileZapsReceived( + cache: ICacheProvider, user: User, since: SincePerRelayMap?, ): List { val relays = user.inboxRelays()?.ifEmpty { null } ?: user.allUsedRelaysOrNull() - ?: LocalCache.relayHints.hintsForKey(user.pubkeyHex) + ?: cache.relayHints.hintsForKey(user.pubkeyHex) return relays.map { relay -> RelayBasedFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFilterAssembler.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFilterAssembler.kt index 2ebb8b1134..d177961418 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFilterAssembler.kt @@ -18,9 +18,10 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient @@ -32,16 +33,17 @@ class UserProfileQueryState( ) class UserProfileFilterAssembler( + cache: ICacheProvider, client: INostrClient, ) : ComposeSubscriptionManager() { val group = listOf( // 5 subs per visible user profile screen. - UserProfileMetadataFilterSubAssembler(client, ::allKeys), - UserProfilePostsFilterSubAssembler(client, ::allKeys), - UserProfileMediaFilterSubAssembler(client, ::allKeys), - UserProfileFollowersFilterSubAssembler(client, ::allKeys), - UserProfileZapsFilterSubAssembler(client, ::allKeys), + UserProfileMetadataFilterSubAssembler(cache, client, ::allKeys), + UserProfilePostsFilterSubAssembler(cache, client, ::allKeys), + UserProfileMediaFilterSubAssembler(cache, client, ::allKeys), + UserProfileFollowersFilterSubAssembler(cache, client, ::allKeys), + UserProfileZapsFilterSubAssembler(cache, client, ::allKeys), ) override fun invalidateFilters() = group.forEach { it.invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFilterAssemblerSubscription.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFilterAssemblerSubscription.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFilterAssemblerSubscription.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFilterAssemblerSubscription.kt index fb69fcdb29..9be26a6260 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFilterAssemblerSubscription.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFilterAssemblerSubscription.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile import androidx.compose.runtime.Composable import androidx.compose.runtime.remember diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFollowersFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFollowersFilterSubAssembler.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFollowersFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFollowersFilterSubAssembler.kt index 721575ea20..bc7efab716 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileFollowersFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileFollowersFilterSubAssembler.kt @@ -18,14 +18,16 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter class UserProfileFollowersFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUserEoseManager(client, allKeys) { @@ -34,7 +36,7 @@ class UserProfileFollowersFilterSubAssembler( since: SincePerRelayMap?, ): List = if (key.loadFollowers) { - filterUserProfileFollowers(user(key), since) + filterUserProfileFollowers(cache, user(key), since) } else { emptyList() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileMediaFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileMediaFilterSubAssembler.kt similarity index 87% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileMediaFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileMediaFilterSubAssembler.kt index a9e6d169f1..4cb5df2449 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileMediaFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileMediaFilterSubAssembler.kt @@ -18,21 +18,23 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter class UserProfileMediaFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUserEoseManager(client, allKeys) { override fun updateFilter( key: UserProfileQueryState, since: SincePerRelayMap?, - ): List = filterUserProfileMedia(user(key), since) + ): List = filterUserProfileMedia(cache, user(key), since) override fun user(key: UserProfileQueryState) = key.user } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileMetadataFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileMetadataFilterSubAssembler.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileMetadataFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileMetadataFilterSubAssembler.kt index acfbc6bdfd..1ca4fade6b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileMetadataFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileMetadataFilterSubAssembler.kt @@ -18,16 +18,17 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.SingleSubEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.utils.mapOfSet class UserProfileMetadataFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : SingleSubEoseManager(client, allKeys) { @@ -41,7 +42,7 @@ class UserProfileMetadataFilterSubAssembler( val relays = user.outboxRelays()?.ifEmpty { null } ?: user.allUsedRelaysOrNull() - ?: LocalCache.relayHints.hintsForKey(user.pubkeyHex) + ?: cache.relayHints.hintsForKey(user.pubkeyHex) relays.forEach { relay -> add(relay, user.pubkeyHex) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfilePostsFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfilePostsFilterSubAssembler.kt similarity index 87% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfilePostsFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfilePostsFilterSubAssembler.kt index cfc6350559..4100c0d796 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfilePostsFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfilePostsFilterSubAssembler.kt @@ -18,21 +18,23 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter class UserProfilePostsFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUserEoseManager(client, allKeys) { override fun updateFilter( key: UserProfileQueryState, since: SincePerRelayMap?, - ): List = filterUserProfilePosts(user(key), since) + ): List = filterUserProfilePosts(cache, user(key), since) override fun user(key: UserProfileQueryState) = key.user } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileZapsFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileZapsFilterSubAssembler.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileZapsFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileZapsFilterSubAssembler.kt index 1e4b7ae68d..880e582c2a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/UserProfileZapsFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/UserProfileZapsFilterSubAssembler.kt @@ -18,14 +18,16 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource +package com.vitorpamplona.amethyst.commons.relayClient.profile +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter class UserProfileZapsFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUserEoseManager(client, allKeys) { @@ -35,7 +37,7 @@ class UserProfileZapsFilterSubAssembler( ): List = if (key.loadZapsReceived) { listOfNotNull( - filterUserProfileZapsReceived(user(key), since), + filterUserProfileZapsReceived(cache, user(key), since), ).flatten() } else { emptyList() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/publicChats/PublicChatsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/publicChats/PublicChatsFilterAssembler.kt index 17253c21c8..9c4519e7db 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/publicChats/datasource/PublicChatsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/publicChats/PublicChatsFilterAssembler.kt @@ -18,34 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.publicChats.datasource +package com.vitorpamplona.amethyst.commons.relayClient.publicChats -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.discover.nip28Chats.makePublicChatsFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class PublicChatsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class PublicChatsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - PublicChatsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makePublicChatsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/FilterPostsByRelay.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/FilterPostsByRelay.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/FilterPostsByRelay.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/FilterPostsByRelay.kt index f4fb8d003e..becd8b7779 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/FilterPostsByRelay.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/FilterPostsByRelay.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.relay.datasource +package com.vitorpamplona.amethyst.commons.relayClient.relay import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/RelayFeedFilterAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/RelayFeedFilterAssembler.kt index a439a9d43a..7f0a70a607 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/RelayFeedFilterAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.relay.datasource +package com.vitorpamplona.amethyst.commons.relayClient.relay import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/RelayFeedFilterSubAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/RelayFeedFilterSubAssembler.kt index 225c50e8ea..e8ffe678e2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relay/datasource/RelayFeedFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/RelayFeedFilterSubAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.relay.datasource +package com.vitorpamplona.amethyst.commons.relayClient.relay import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relays/RelayInfoNip66FilterAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relays/RelayInfoNip66FilterAssembler.kt index 8a2654284a..b706d713e5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relays/RelayInfoNip66FilterAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.datasource +package com.vitorpamplona.amethyst.commons.relayClient.relays import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relays/RelayInfoNip66FilterSubAssembler.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relays/RelayInfoNip66FilterSubAssembler.kt index e243608056..f914cd99d9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/datasource/RelayInfoNip66FilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relays/RelayInfoNip66FilterSubAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.datasource +package com.vitorpamplona.amethyst.commons.relayClient.relays import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByAddress.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByAddress.kt similarity index 85% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByAddress.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByAddress.kt index df31d45479..657eca9236 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByAddress.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByAddress.kt @@ -18,26 +18,27 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.relayClient.searchCommand.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.search +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.filterMissingAddressables import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.potentialRelaysToFindAddress -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress import com.vitorpamplona.quartz.utils.mapOfSet fun filterByAddress( + cache: ICacheProvider, address: NAddress, default: Set, ): List { - val note = LocalCache.getOrCreateAddressableNote(address.address()) + val note = cache.getOrCreateAddressableNote(address.address()) val list = mapOfSet { if (note.event == null) { - potentialRelaysToFindAddress(LocalCache, note).ifEmpty { default }.forEach { relayUrl -> + potentialRelaysToFindAddress(cache, note).ifEmpty { default }.forEach { relayUrl -> add(relayUrl, note.address) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByAuthor.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByAuthor.kt similarity index 87% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByAuthor.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByAuthor.kt index 70973ab169..cdb14b6a3d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByAuthor.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByAuthor.kt @@ -18,11 +18,11 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.relayClient.searchCommand.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.search +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @@ -32,15 +32,16 @@ import com.vitorpamplona.quartz.utils.mapOfSet val MetadataKindList = listOf(MetadataEvent.KIND) fun filterByAuthor( + cache: ICacheProvider, pubKey: HexKey, indexRelays: Set, defaultRelays: Set, -) = LocalCache.checkGetOrCreateUser(pubKey)?.let { key -> +) = cache.checkGetOrCreateUser(pubKey)?.let { key -> val perRelay = mapOfSet { val relays = key.authorRelayList()?.writeRelaysNorm() - ?: (key.allUsedRelays() + LocalCache.relayHints.hintsForKey(key.pubkeyHex) + indexRelays).ifEmpty { null } + ?: (key.allUsedRelays() + cache.relayHints.hintsForKey(key.pubkeyHex) + indexRelays).ifEmpty { null } ?: defaultRelays.toList() relays.forEach { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByEvent.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByEvent.kt similarity index 83% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByEvent.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByEvent.kt index 6265f852cb..f557d815f9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/FilterByEvent.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/FilterByEvent.kt @@ -18,27 +18,28 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.relayClient.searchCommand.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.search import com.vitorpamplona.amethyst.commons.model.AddressableNote +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.filterMissingEvents import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.potentialRelaysToFindEvent -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.utils.mapOfSet fun filterByEvent( + cache: ICacheProvider, eventId: HexKey, default: Set, ): List { - val note = LocalCache.checkGetOrCreateNote(eventId) ?: return emptyList() + val note = cache.checkGetOrCreateNote(eventId) ?: return emptyList() val list = mapOfSet { if (note !is AddressableNote && note.event == null) { - potentialRelaysToFindEvent(LocalCache, note).ifEmpty { default }.forEach { relayUrl -> + potentialRelaysToFindEvent(cache, note).ifEmpty { default }.forEach { relayUrl -> add(relayUrl, note.idHex) } } @@ -46,7 +47,7 @@ fun filterByEvent( // loads threading that is event-based note.replyTo?.forEach { parentNote -> if (parentNote !is AddressableNote && parentNote.event == null) { - potentialRelaysToFindEvent(LocalCache, parentNote).ifEmpty { default }.forEach { relayUrl -> + potentialRelaysToFindEvent(cache, parentNote).ifEmpty { default }.forEach { relayUrl -> add(relayUrl, parentNote.idHex) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/SearchPostWatcherSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchPostWatcherSubAssembler.kt similarity index 83% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/SearchPostWatcherSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchPostWatcherSubAssembler.kt index dcdd9d3d9c..8d34e37f3f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/SearchPostWatcherSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchPostWatcherSubAssembler.kt @@ -18,13 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.relayClient.searchCommand.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.search +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.search.searchPostsByText import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache -import com.vitorpamplona.amethyst.service.relayClient.searchCommand.SearchQueryState import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @@ -44,7 +43,7 @@ import com.vitorpamplona.quartz.utils.Hex * that has the search ter is the id of the sub. */ class SearchPostWatcherSubAssembler( - val cache: LocalCache, + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUniqueIdEoseManager(client, allKeys) { @@ -56,13 +55,13 @@ class SearchPostWatcherSubAssembler( if (mySearchString.isBlank()) return null - val defaultRelaysWithSearch = key.account.followPlusAllMineWithSearch.flow.value + val defaultRelaysWithSearch = key.followPlusAllMineWithSearchRelays.value val directFilters = runCatching { if (Hex.isHex(mySearchString)) { val hexKey = Hex.decode(mySearchString).toHexKey() - filterByEvent(hexKey, defaultRelaysWithSearch) + filterByEvent(cache, hexKey, defaultRelaysWithSearch) } else { val parsed = Nip19Parser.uriToRoute(mySearchString)?.entity if (parsed != null) { @@ -72,11 +71,11 @@ class SearchPostWatcherSubAssembler( is NSec -> emptyList() is NPub -> emptyList() is NProfile -> emptyList() - is NNote -> filterByEvent(parsed.hex, defaultRelaysWithSearch) - is NEvent -> filterByEvent(parsed.hex, defaultRelaysWithSearch) + is NNote -> filterByEvent(cache, parsed.hex, defaultRelaysWithSearch) + is NEvent -> filterByEvent(cache, parsed.hex, defaultRelaysWithSearch) is NEmbed -> emptyList() is NRelay -> emptyList() - is NAddress -> filterByAddress(parsed, defaultRelaysWithSearch) + is NAddress -> filterByAddress(cache, parsed, defaultRelaysWithSearch) else -> emptyList() } } else { @@ -86,7 +85,7 @@ class SearchPostWatcherSubAssembler( }.getOrDefault(emptyList()) val searchFilters = - key.account.searchRelayList.flow.value.flatMap { + key.searchRelays.value.flatMap { searchPostsByText(mySearchString, it) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchQueryState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchQueryState.kt new file mode 100644 index 0000000000..51c4f6ef5c --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchQueryState.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.search + +import androidx.compose.runtime.Stable +import com.vitorpamplona.amethyst.commons.model.IAccount +import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.MutableQueryState +import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow + +/** + * A live search box. The [searchQuery] flow is the subscription id: every edit re-issues the + * REQs, so the sub-assemblers read the relay lists as snapshots at filter-build time. + * + * @param searchRelays NIP-50 search relays (kind 10007), for full-text people/post search. + * @param indexerRelays indexer relays, tried first when the query is a bare pubkey / npub / nprofile. + * @param followPlusAllMineWithSearchRelays follows' outboxes + every relay of mine + the search + * relays; the fallback set for a direct id lookup that no hint resolves. + */ +@Stable +class SearchQueryState( + val searchQuery: MutableStateFlow, + override val account: IAccount, + val searchRelays: StateFlow>, + val indexerRelays: StateFlow>, + val followPlusAllMineWithSearchRelays: StateFlow>, +) : MutableQueryState, + AccountScopedQuery { + override fun flow(): Flow = searchQuery +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/SearchUserWatcherSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchUserWatcherSubAssembler.kt similarity index 82% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/SearchUserWatcherSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchUserWatcherSubAssembler.kt index fb4d97b39f..d79bd81a58 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/searchCommand/subassemblies/SearchUserWatcherSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/search/SearchUserWatcherSubAssembler.kt @@ -18,14 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.relayClient.searchCommand.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.search import com.vitorpamplona.amethyst.commons.defaults.DefaultIndexerRelayList +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relayClient.search.searchPeopleByName import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache -import com.vitorpamplona.amethyst.service.relayClient.searchCommand.SearchQueryState import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @@ -45,7 +44,7 @@ import com.vitorpamplona.quartz.utils.Hex * that has the search ter is the id of the sub. */ class SearchUserWatcherSubAssembler( - val cache: LocalCache, + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : PerUniqueIdEoseManager(client, allKeys) { @@ -58,24 +57,24 @@ class SearchUserWatcherSubAssembler( if (mySearchString.isBlank()) return null val indexRelays = - key.account.indexerRelayList.flow.value + key.indexerRelays.value .ifEmpty { DefaultIndexerRelayList } - val defaultRelaysWithSearch = key.account.followPlusAllMineWithSearch.flow.value + val defaultRelaysWithSearch = key.followPlusAllMineWithSearchRelays.value val directFilters = runCatching { if (Hex.isHex(mySearchString)) { val hexKey = Hex.decode(mySearchString).toHexKey() - filterByAuthor(hexKey, indexRelays, defaultRelaysWithSearch) + filterByAuthor(cache, hexKey, indexRelays, defaultRelaysWithSearch) } else { val parsed = Nip19Parser.uriToRoute(mySearchString)?.entity if (parsed != null) { cache.consume(parsed) when (parsed) { - is NSec -> filterByAuthor(parsed.toPubKeyHex(), indexRelays, defaultRelaysWithSearch) - is NPub -> filterByAuthor(parsed.hex, indexRelays, defaultRelaysWithSearch) - is NProfile -> filterByAuthor(parsed.hex, indexRelays, defaultRelaysWithSearch) + is NSec -> filterByAuthor(cache, parsed.toPubKeyHex(), indexRelays, defaultRelaysWithSearch) + is NPub -> filterByAuthor(cache, parsed.hex, indexRelays, defaultRelaysWithSearch) + is NProfile -> filterByAuthor(cache, parsed.hex, indexRelays, defaultRelaysWithSearch) is NNote -> emptyList() is NEvent -> emptyList() is NEmbed -> emptyList() @@ -90,7 +89,7 @@ class SearchUserWatcherSubAssembler( }.getOrDefault(emptyList()) val searchFilters = - key.account.searchRelayList.flow.value.flatMap { + key.searchRelays.value.flatMap { searchPeopleByName(mySearchString, it) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterPollsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAllCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterPollsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAllCommunities.kt index 89df797159..18bcd8b0fa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterPollsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.shorts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAuthors.kt index 293b5b9d5e..24bca3c574 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.shorts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByFollows.kt index d37ff51133..2d142f7f73 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.shorts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByGeohashes.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByGeohashes.kt index 5b6f11fee9..c9afffb742 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.shorts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByHashtag.kt index fc20059001..dfe7382fe8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.shorts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsGlobal.kt index 8c6af542c4..ee0c14a2b1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/subassemblies/FilterShortsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.shorts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/ShortsFilterAssembler.kt similarity index 56% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/ShortsFilterAssembler.kt index 4d6c3446cb..7fc32ab4c9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/ShortsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/ShortsFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.shorts -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class ShortsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class ShortsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - ShortsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeShortsFilter)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/SubAssemblyHelper.kt similarity index 78% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/SubAssemblyHelper.kt index d74ea95a24..1bd30fdf12 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.shorts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -29,16 +29,16 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommuni import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.shorts.filterShortsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.datasource.subassemblies.filterShortsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeShortsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByAuthors.kt index b252ee3e38..5eda45cb9b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.softwareapps import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByFollows.kt index bb98b728dd..da40b9e1ed 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.softwareapps import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByHashtag.kt index 9e0b5eecf6..638eee590e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.softwareapps import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsGlobal.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsGlobal.kt index 6fe9f294d9..ed54dbf12d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/subassemblies/FilterSoftwareAppsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.softwareapps import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SoftwareAppsFilterAssembler.kt similarity index 50% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SoftwareAppsFilterAssembler.kt index 06f8cb5ad1..556b379a9a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SoftwareAppsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SoftwareAppsFilterAssembler.kt @@ -18,34 +18,32 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource +package com.vitorpamplona.amethyst.commons.relayClient.softwareapps -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.model.IAccount +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState +import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient +import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.StateFlow +/** + * Key for the Apps feed. Besides the usual top-nav inputs it carries the user's blocked-relay set: + * the Global selection queries zapstore's relay directly, and must stop when the user blocks it. + */ class SoftwareAppsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery + account: IAccount, + listName: StateFlow, + followsPerRelay: StateFlow, + scope: CoroutineScope, + feed: FeedContentState, + val blockedRelays: StateFlow>, +) : TopNavFeedQueryState(account, listName, followsPerRelay, scope, listOf(feed)) -@Stable class SoftwareAppsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - SoftwareAppsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SoftwareAppsSubAssembler(client, keys)) }) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SoftwareAppsSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SoftwareAppsSubAssembler.kt new file mode 100644 index 0000000000..63782c645a --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SoftwareAppsSubAssembler.kt @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.softwareapps + +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient +import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter +import kotlinx.coroutines.flow.Flow + +class SoftwareAppsSubAssembler( + client: INostrClient, + allKeys: () -> Set, +) : TopNavFeedSubAssembler(client, allKeys) { + override fun updateFilter( + key: SoftwareAppsQueryState, + since: SincePerRelayMap?, + ): List = + makeSoftwareAppsFilter( + key.followsPerRelay.value, + since, + key.feeds.first().lastNoteCreatedAtIfFilled(), + key.blockedRelays.value, + ) + + // Re-evaluate when the user blocks/unblocks zapstore's relay so the global Apps feed + // stops/starts querying it without a restart. + override fun extraInvalidators(key: SoftwareAppsQueryState): List> = listOf(key.blockedRelays) +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SubAssemblyHelper.kt similarity index 81% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SubAssemblyHelper.kt index efc575b865..f0ee0a6833 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/softwareapps/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource +package com.vitorpamplona.amethyst.commons.relayClient.softwareapps import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -26,13 +26,13 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavP import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.filterSoftwareAppsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.filterSoftwareAppsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.filterSoftwareAppsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.filterSoftwareAppsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.softwareapps.filterSoftwareAppsGlobal import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies.filterSoftwareAppsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies.filterSoftwareAppsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies.filterSoftwareAppsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies.filterSoftwareAppsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.softwareapps.datasource.subassemblies.filterSoftwareAppsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/FilterEventsInThreadForRoot.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/thread/FilterEventsInThreadForRoot.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/FilterEventsInThreadForRoot.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/thread/FilterEventsInThreadForRoot.kt index 7ddd3081bf..b730f90b89 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/FilterEventsInThreadForRoot.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/thread/FilterEventsInThreadForRoot.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.threadview.datasources.subassembies +package com.vitorpamplona.amethyst.commons.relayClient.thread import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/FilterMissingEventsForThread.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/thread/FilterMissingEventsForThread.kt similarity index 85% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/FilterMissingEventsForThread.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/thread/FilterMissingEventsForThread.kt index 1ac0575586..f9e3bb079f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/datasources/subassembies/FilterMissingEventsForThread.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/thread/FilterMissingEventsForThread.kt @@ -18,34 +18,35 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.threadview.datasources.subassembies +package com.vitorpamplona.amethyst.commons.relayClient.thread import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.ThreadAssembler +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.filterMissingAddressables import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.filterMissingEvents import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.potentialRelaysToFindAddress import com.vitorpamplona.amethyst.commons.relayClient.event.loaders.potentialRelaysToFindEvent -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.utils.mapOfSet fun filterMissingEventsForThread( + cache: ICacheProvider, threadInfo: ThreadAssembler.ThreadInfo, defaultRelays: Set, ): List { val missingEvents = mapOfSet { if (threadInfo.root.event == null && threadInfo.root !is AddressableNote) { - potentialRelaysToFindEvent(LocalCache, threadInfo.root).ifEmpty { defaultRelays }.forEach { relayUrl -> + potentialRelaysToFindEvent(cache, threadInfo.root).ifEmpty { defaultRelays }.forEach { relayUrl -> add(relayUrl, threadInfo.root.idHex) } } threadInfo.allNotes.forEach { if (it !is AddressableNote && it.event == null) { - potentialRelaysToFindEvent(LocalCache, it).ifEmpty { defaultRelays }.forEach { relayUrl -> + potentialRelaysToFindEvent(cache, it).ifEmpty { defaultRelays }.forEach { relayUrl -> add(relayUrl, it.idHex) } } @@ -60,14 +61,14 @@ fun filterMissingEventsForThread( // note's aTag idHex into the hex-keyed event-hint index, which throws // on the non-hex string and kills the whole filter build — leaving a // thread opened on an uncached naddr permanently unfetched. - potentialRelaysToFindAddress(LocalCache, rootNote).ifEmpty { defaultRelays }.forEach { relayUrl -> + potentialRelaysToFindAddress(cache, rootNote).ifEmpty { defaultRelays }.forEach { relayUrl -> add(relayUrl, rootNote.address) } } threadInfo.allNotes.forEach { if (it is AddressableNote && it.event == null) { - potentialRelaysToFindAddress(LocalCache, it).ifEmpty { defaultRelays }.forEach { relayUrl -> + potentialRelaysToFindAddress(cache, it).ifEmpty { defaultRelays }.forEach { relayUrl -> add(relayUrl, it.address) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedFilterAssembler.kt similarity index 65% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedFilterAssembler.kt index e89a5556f4..79e45d4329 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/datasource/ArticlesFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedFilterAssembler.kt @@ -18,30 +18,23 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.articles.datasource +package com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates -import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope - -class ArticlesQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery +import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager +/** + * Compose-scoped subscription manager for a top-nav feed: owns the feed's sub-assemblers and fans + * key/filter invalidation out to them. Registered once per app lifetime (the EOSE managers open + * their relay subscription at construction), so it must not be created per screen. + */ @Stable -class ArticlesFilterAssembler( - client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - ArticlesSubAssembler(client, ::allKeys), - ) +open class TopNavFeedFilterAssembler( + subAssemblers: (allKeys: () -> Set) -> List>, +) : ComposeSubscriptionManager() { + val group = subAssemblers(::allKeys) override fun invalidateKeys() = invalidateFilters() diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedQueryState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedQueryState.kt new file mode 100644 index 0000000000..cccea29ddd --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedQueryState.kt @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds + +import com.vitorpamplona.amethyst.commons.model.IAccount +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery +import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.StateFlow + +/** + * Key for a feed subscription driven by the top-nav selector: the list the user picked + * ([listName]), that list resolved through the outbox model into per-relay author/tag sets + * ([followsPerRelay]), and the feed(s) whose oldest loaded note bounds the REQ's `since` + * ([feeds] — empty for screens that read the cache directly, such as nSites and nApplets). + * + * One key per open screen: several screens may show the same feed at once, each with its own key. + * Watchers launched for the key run on [scope], the screen's scope. + */ +open class TopNavFeedQueryState( + override val account: IAccount, + val listName: StateFlow, + val followsPerRelay: StateFlow, + val scope: CoroutineScope, + val feeds: List = emptyList(), +) : AccountScopedQuery diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedSubAssembler.kt new file mode 100644 index 0000000000..7814d09d72 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/topNavFeeds/TopNavFeedSubAssembler.kt @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds + +import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUserAndFollowListEoseManager +import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient +import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter +import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.IO +import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.sample +import kotlinx.coroutines.launch + +/** Turns a resolved top-nav selection into the per-relay REQs for one feed kind. */ +typealias TopNavFeedFilterMaker = ( + feedSettings: IFeedTopNavPerRelayFilterSet, + since: SincePerRelayMap?, + defaultSince: Long?, +) -> List + +/** + * The EOSE manager every top-nav-driven feed shares: one relay subscription per logged-in user + + * selected list, re-issued when the selection changes, when its per-relay resolution changes, or + * when a watched feed floor moves. Subclasses supply [updateFilter]; [floors], [onListChanged] and + * [extraInvalidators] tune what re-issues the REQ. + */ +abstract class TopNavFeedSubAssembler( + client: INostrClient, + allKeys: () -> Set, +) : PerUserAndFollowListEoseManager(client, allKeys) { + override fun user(key: K) = key.account.userProfile() + + override fun list(key: K) = key.listName.value + + /** Runs when the key's top-nav selection changes, right before the filters are re-issued. */ + protected open fun onListChanged(key: K) {} + + /** How often (ms) a moving feed floor may re-issue the REQ; the video swipe feed wants a tighter cadence. */ + protected open val floorSampleMs: Long = 5000 + + /** The feed floors that re-issue the REQ (sampled) when they move. Defaults to every feed on the key. */ + protected open fun floors(key: K): List> = key.feeds.map { it.lastNoteCreatedAtWhenFullyLoaded } + + /** Additional flows whose every emission re-issues the REQ, unsampled. */ + protected open fun extraInvalidators(key: K): List> = emptyList() + + private val userJobMap = mutableMapOf>() + + @OptIn(FlowPreview::class) + override fun newSub(key: K): Subscription { + val user = user(key) + userJobMap[user]?.forEach { it.cancel() } + userJobMap[user] = + buildList { + add( + key.scope.launch(Dispatchers.IO) { + key.listName.collectLatest { + onListChanged(key) + invalidateFilters() + } + }, + ) + add( + key.scope.launch(Dispatchers.IO) { + key.followsPerRelay.sample(500).collectLatest { + invalidateFilters() + } + }, + ) + val floors = floors(key) + if (floors.isNotEmpty()) { + add( + key.scope.launch(Dispatchers.IO) { + combine(floors) { }.sample(floorSampleMs).collectLatest { + invalidateFilters() + } + }, + ) + } + extraInvalidators(key).forEach { flow -> + add( + key.scope.launch(Dispatchers.IO) { + flow.collectLatest { + invalidateFilters() + } + }, + ) + } + } + + return super.newSub(key) + } + + override fun endSub( + key: User, + subId: String, + ) { + super.endSub(key, subId) + userJobMap.remove(key)?.forEach { it.cancel() } + } +} + +/** + * A top-nav feed whose REQ is one [makeFilter] dispatcher over the selection, bounded by the + * key's (single) feed floor. + * + * @param resetEoseOnListChange drop the per-relay EOSE cursor when the user switches lists. Needed + * when the feed shows addressables held only weakly by the cache: while the user views list B the + * strong refs from list A's UI are gone and the GC may reclaim those notes; a cursor that still + * says "you have everything up to T" would then stop the relay from re-sending them. + */ +open class SingleTopNavFeedSubAssembler( + client: INostrClient, + allKeys: () -> Set, + private val makeFilter: TopNavFeedFilterMaker, + private val resetEoseOnListChange: Boolean = false, + override val floorSampleMs: Long = 5000, +) : TopNavFeedSubAssembler(client, allKeys) { + override fun updateFilter( + key: TopNavFeedQueryState, + since: SincePerRelayMap?, + ): List = makeFilter(key.followsPerRelay.value, since, key.feeds.firstOrNull()?.lastNoteCreatedAtIfFilled()) + + override fun onListChanged(key: TopNavFeedQueryState) { + if (resetEoseOnListChange) clearEoseFor(key) + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/FilterPostsByUrl.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/FilterPostsByUrl.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/FilterPostsByUrl.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/FilterPostsByUrl.kt index bf804ca564..7add95eede 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/FilterPostsByUrl.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/FilterPostsByUrl.kt @@ -18,12 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.url.datasource +package com.vitorpamplona.amethyst.commons.relayClient.url +import com.vitorpamplona.amethyst.commons.relayClient.nip22Comments.CommentKinds import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments.CommentKinds import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip73ExternalIds.urls.UrlId diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFeedFilterSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/UrlFeedFilterSubAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFeedFilterSubAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/UrlFeedFilterSubAssembler.kt index c217ca8df2..95db0ce6e7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFeedFilterSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/UrlFeedFilterSubAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.url.datasource +package com.vitorpamplona.amethyst.commons.relayClient.url import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.PerUniqueIdEoseManager import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/UrlFilterAssembler.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/UrlFilterAssembler.kt index aecde52c29..9240162a70 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/UrlFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/UrlFilterAssembler.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.url.datasource +package com.vitorpamplona.amethyst.commons.relayClient.url import androidx.compose.runtime.Stable import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/FeedBasis.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/FeedBasis.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/FeedBasis.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/FeedBasis.kt index 3022cc997a..e88becb372 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/FeedBasis.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/FeedBasis.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource +package com.vitorpamplona.amethyst.commons.relayClient.video import com.vitorpamplona.quartz.experimental.nip95.header.FileStorageHeaderEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/SubAssemblyHelper.kt new file mode 100644 index 0000000000..947da595b5 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/SubAssemblyHelper.kt @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.video + +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core.filterPictureAndVideoByGeohash +import com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core.filterPictureAndVideoByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core.filterPictureAndVideoGlobal +import com.vitorpamplona.amethyst.commons.relayClient.video.nip65Follows.filterPictureAndVideoByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.video.nip65Follows.filterPictureAndVideoByFollows +import com.vitorpamplona.amethyst.commons.relayClient.video.nip72Communities.filterPictureAndVideoByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.video.nip72Communities.filterPictureAndVideoByCommunity +import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap +import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter +import com.vitorpamplona.quartz.utils.TimeUtils + +/** + * Maps the top-nav selection to the picture/video feed's REQs. Global and hashtag selections fall + * back to a week / a month of history when the feed has no floor yet, so a cold start does not + * pull every relay's whole media history. + */ +fun makePictureAndVideoFilter( + feedSettings: IFeedTopNavPerRelayFilterSet, + since: SincePerRelayMap?, + defaultSince: Long? = null, +): List = + when (feedSettings) { + is AllCommunitiesTopNavPerRelayFilterSet -> filterPictureAndVideoByAllCommunities(feedSettings, since, defaultSince) + is AllFollowsTopNavPerRelayFilterSet -> filterPictureAndVideoByFollows(feedSettings, since, defaultSince) + is AuthorsTopNavPerRelayFilterSet -> filterPictureAndVideoByAuthors(feedSettings, since, defaultSince) + is GlobalTopNavPerRelayFilterSet -> filterPictureAndVideoGlobal(feedSettings, since, defaultSince ?: TimeUtils.oneWeekAgo()) + is HashtagTopNavPerRelayFilterSet -> filterPictureAndVideoByHashtag(feedSettings, since, defaultSince ?: TimeUtils.oneMonthAgo()) + is LocationTopNavPerRelayFilterSet -> filterPictureAndVideoByGeohash(feedSettings, since, defaultSince) + is MutedAuthorsTopNavPerRelayFilterSet -> filterPictureAndVideoByAuthors(feedSettings, since, defaultSince) + is SingleCommunityTopNavPerRelayFilterSet -> filterPictureAndVideoByCommunity(feedSettings, since, defaultSince) + else -> emptyList() + } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/VideoFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/VideoFilterAssembler.kt new file mode 100644 index 0000000000..b1e8852e91 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/VideoFilterAssembler.kt @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relayClient.video + +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState +import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient + +class VideoFilterAssembler( + client: INostrClient, +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makePictureAndVideoFilter, floorSampleMs = 1000)) }) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoByGeohash.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByGeohash.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoByGeohash.kt index 904a71ad51..86de03f03b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoByGeohash.kt @@ -18,15 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core +package com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose +import com.vitorpamplona.amethyst.commons.relayClient.video.LegacyMimeTypes +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKinds +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoLegacyKinds import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.LegacyMimeTypes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKinds -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoLegacyKinds import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoByHashtag.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoByHashtag.kt index e2dda44270..7a3912f443 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoByHashtag.kt @@ -18,15 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core +package com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose +import com.vitorpamplona.amethyst.commons.relayClient.video.LegacyMimeTypes +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKinds +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoLegacyKinds import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.LegacyMimeTypes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKinds -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoLegacyKinds import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtagAlts diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoGlobal.kt similarity index 87% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoGlobal.kt index 673952b32a..08747ee4b4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip01Core/FilterPictureAndVideoGlobal.kt @@ -18,15 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core +package com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose +import com.vitorpamplona.amethyst.commons.relayClient.video.LegacyMimeTypeMap +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKinds +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoLegacyKinds import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.LegacyMimeTypeMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKinds -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoLegacyKinds import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun filterPictureAndVideoGlobal( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip65Follows/FilterPictureAndVideoByAuthors.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip65Follows/FilterPictureAndVideoByAuthors.kt index b27d9d63f6..040368e820 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip65Follows/FilterPictureAndVideoByAuthors.kt @@ -18,16 +18,16 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip65Follows +package com.vitorpamplona.amethyst.commons.relayClient.video.nip65Follows import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose +import com.vitorpamplona.amethyst.commons.relayClient.video.LegacyMimeTypeMap +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKinds +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoLegacyKinds import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.LegacyMimeTypeMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKinds -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoLegacyKinds import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip65Follows/FilterPictureAndVideoByFollows.kt similarity index 82% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip65Follows/FilterPictureAndVideoByFollows.kt index 4498c0dbe7..86826e7c73 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip65Follows/FilterPictureAndVideoByFollows.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip65Follows +package com.vitorpamplona.amethyst.commons.relayClient.video.nip65Follows import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core.filterPictureAndVideoGeohash +import com.vitorpamplona.amethyst.commons.relayClient.video.nip01Core.filterPictureAndVideoHashtag +import com.vitorpamplona.amethyst.commons.relayClient.video.nip72Communities.filterPictureAndVideoAllCommunities import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core.filterPictureAndVideoGeohash -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip01Core.filterPictureAndVideoHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip72Communities.filterPictureAndVideoAllCommunities import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun filterPictureAndVideoByFollows( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByAllCommunities.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByAllCommunities.kt index c55497a0ab..530b8a2d2c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByAllCommunities.kt @@ -18,16 +18,16 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip72Communities +package com.vitorpamplona.amethyst.commons.relayClient.video.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose +import com.vitorpamplona.amethyst.commons.relayClient.video.LegacyMimeTypes +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKTags +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKinds +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoLegacyKinds import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.LegacyMimeTypes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKTags -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKinds -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoLegacyKinds import com.vitorpamplona.quartz.experimental.nip95.header.FileStorageHeaderEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByCommunity.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByCommunity.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByCommunity.kt index db41d2dbf7..a447780806 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByCommunity.kt @@ -18,17 +18,17 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.subassemblies.nip72Communities +package com.vitorpamplona.amethyst.commons.relayClient.video.nip72Communities import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose +import com.vitorpamplona.amethyst.commons.relayClient.video.LegacyMimeTypes +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKTags +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoKinds +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoLegacyKTags +import com.vitorpamplona.amethyst.commons.relayClient.video.PictureAndVideoLegacyKinds import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.LegacyMimeTypes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKTags -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoKinds -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoLegacyKTags -import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.PictureAndVideoLegacyKinds import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/datasource/OnchainZapsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/wallet/OnchainZapsFilterAssembler.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/datasource/OnchainZapsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/wallet/OnchainZapsFilterAssembler.kt index 6fffcfdc55..87b0ab558d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/datasource/OnchainZapsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/wallet/OnchainZapsFilterAssembler.kt @@ -18,15 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.wallet.datasource +package com.vitorpamplona.amethyst.commons.relayClient.wallet import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.SingleSubEoseManager import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl @@ -97,6 +97,7 @@ private fun filterOnchainZaps( } class OnchainZapsFilterSubAssembler( + val cache: ICacheProvider, client: INostrClient, allKeys: () -> Set, ) : SingleSubEoseManager(client, allKeys) { @@ -110,7 +111,7 @@ class OnchainZapsFilterSubAssembler( user.inboxRelays()?.ifEmpty { null } ?: user.outboxRelays()?.ifEmpty { null } ?: user.allUsedRelaysOrNull() - ?: LocalCache.relayHints.hintsForKey(user.pubkeyHex) + ?: cache.relayHints.hintsForKey(user.pubkeyHex) if (relays.isEmpty()) return emptyList() // Take the tightest window across all live keys — if any subscriber @@ -128,9 +129,10 @@ class OnchainZapsFilterSubAssembler( } class OnchainZapsFilterAssembler( + cache: ICacheProvider, client: INostrClient, ) : ComposeSubscriptionManager() { - private val sub = OnchainZapsFilterSubAssembler(client, ::allKeys) + private val sub = OnchainZapsFilterSubAssembler(cache, client, ::allKeys) override fun invalidateFilters() = sub.invalidateFilters() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByAllCommunities.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByAllCommunities.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByAllCommunities.kt index b42dd4386e..ca113c9761 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByAllCommunities.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.workouts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByAuthors.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByAuthors.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByAuthors.kt index 1f31d851c2..7b9e3c1eb8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByAuthors.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.workouts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByFollows.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByFollows.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByFollows.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByFollows.kt index 60e5a73698..7b668457c8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByFollows.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByFollows.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.workouts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByGeohashes.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByGeohashes.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByGeohashes.kt index bea6faae7d..3fe1fe81aa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByGeohashes.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.workouts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByHashtag.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByHashtag.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByHashtag.kt index ecc6d9315e..2061ec71ba 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsByHashtag.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.workouts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsGlobal.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsGlobal.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsGlobal.kt index 197f49ce52..0739b19b48 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/subassemblies/FilterWorkoutsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/FilterWorkoutsGlobal.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.workouts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/SubAssemblyHelper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/SubAssemblyHelper.kt similarity index 77% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/SubAssemblyHelper.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/SubAssemblyHelper.kt index abe1a3827c..464372e8e4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/SubAssemblyHelper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/SubAssemblyHelper.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.workouts import com.vitorpamplona.amethyst.commons.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet @@ -30,15 +30,15 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.Aut import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.scopedTo +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsByAllCommunities +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsByAuthors +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsByCommunity +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsByFollows +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsByGeohashes +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsByHashtag +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsByMutedAuthors +import com.vitorpamplona.amethyst.commons.relayClient.workouts.filterWorkoutsGlobal import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsByAllCommunities -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsByGeohashes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsByHashtag -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsByMutedAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource.subassemblies.filterWorkoutsGlobal import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeWorkoutsFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsFilterAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/WorkoutsFilterAssembler.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsFilterAssembler.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/WorkoutsFilterAssembler.kt index 36fc9136d8..88d8be0668 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/datasource/WorkoutsFilterAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/workouts/WorkoutsFilterAssembler.kt @@ -18,34 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.workouts.datasource +package com.vitorpamplona.amethyst.commons.relayClient.workouts -import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.relayClient.AccountScopedQuery -import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.SingleTopNavFeedSubAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedFilterAssembler +import com.vitorpamplona.amethyst.commons.relayClient.topNavFeeds.TopNavFeedQueryState import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient -import kotlinx.coroutines.CoroutineScope -class WorkoutsQueryState( - override val account: Account, - val feedStates: AccountFeedContentStates, - val scope: CoroutineScope, -) : AccountScopedQuery - -@Stable class WorkoutsFilterAssembler( client: INostrClient, -) : ComposeSubscriptionManager() { - val group = - listOf( - WorkoutsSubAssembler(client, ::allKeys), - ) - - override fun invalidateKeys() = invalidateFilters() - - override fun invalidateFilters() = group.forEach { it.invalidateFilters() } - - override fun destroy() = group.forEach { it.destroy() } -} +) : TopNavFeedFilterAssembler({ keys -> listOf(SingleTopNavFeedSubAssembler(client, keys, ::makeWorkoutsFilter)) }) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt index 3bbc6bbc5d..5bed98dc6f 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt @@ -192,6 +192,8 @@ class ThreadAssemblerTest { override fun getOrCreateUser(pubkey: HexKey): User? = null + override fun consumeEmbedded(event: Event) = Unit + override fun justConsumeMyOwnEvent(event: Event): Boolean = false } } diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordChannelListLeaveTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordChannelListLeaveTest.kt index 298295d60c..272e9da38c 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordChannelListLeaveTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordChannelListLeaveTest.kt @@ -101,6 +101,8 @@ class ConcordChannelListLeaveTest { override fun getOrCreateUser(pubkey: HexKey): User? = null + override fun consumeEmbedded(event: Event) = Unit + override fun justConsumeMyOwnEvent(event: Event): Boolean = false } diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordListLateArrivalTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordListLateArrivalTest.kt index 6c682a88fc..af29a84fff 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordListLateArrivalTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/concord/ConcordListLateArrivalTest.kt @@ -99,6 +99,8 @@ class ConcordListLateArrivalTest { override fun getOrCreateUser(pubkey: HexKey): User? = null + override fun consumeEmbedded(event: Event) = Unit + override fun justConsumeMyOwnEvent(event: Event): Boolean = false } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterRelayGroupStateTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupStateTest.kt similarity index 88% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterRelayGroupStateTest.kt rename to commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupStateTest.kt index 82a772f8ef..d0ef97fdf9 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/datasource/subassemblies/FilterRelayGroupStateTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupStateTest.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer @@ -28,11 +28,11 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNull +import kotlin.test.assertTrue /** * The relay-group branch of the open-channel filter (`ChannelPublic`). After the state/content split this @@ -65,8 +65,8 @@ class FilterRelayGroupStateTest { filters.forEach { f -> assertEquals(relayA, f.relay) assertEquals(listOf("g1"), f.filter.tags!!["d"]) - assertNull("state is #d-scoped, never #h — the message window is the tail/pager's job", f.filter.tags!!["h"]) - assertNull("state carries no message-window kinds (9/poll), so no limit either", f.filter.limit) + assertNull(f.filter.tags!!["h"], "state is #d-scoped, never #h — the message window is the tail/pager's job") + assertNull(f.filter.limit, "state carries no message-window kinds (9/poll), so no limit either") assertNull(f.filter.until) } assertEquals(metadataKinds, filters[0].filter.kinds) @@ -87,8 +87,8 @@ class FilterRelayGroupStateTest { filterRelayGroupState(channel, since = null).forEach { f -> val kinds = f.filter.kinds ?: return@forEach assertFalse( - "39005 must not share a filter with the 39000-39003 metadata block: $kinds", kinds.contains(GroupPinnedEvent.KIND) && kinds.any { it in metadataKinds }, + "39005 must not share a filter with the 39000-39003 metadata block: $kinds", ) } } @@ -114,8 +114,8 @@ class FilterRelayGroupStateTest { val pinFilter = filters.first { it.filter.ids != null } assertEquals(relayA, pinFilter.relay) assertEquals(pinnedIds, pinFilter.filter.ids) - assertNull("pinned bodies are fetched by id, so no kinds", pinFilter.filter.kinds) - assertNull("pinned events are immutable, so no since either", pinFilter.filter.since) + assertNull(pinFilter.filter.kinds, "pinned bodies are fetched by id, so no kinds") + assertNull(pinFilter.filter.since, "pinned events are immutable, so no since either") // The state filters are still present and still carry no #h message window. val stateFilters = filters.filter { it.filter.ids == null } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByAuthorsTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByAuthorsTest.kt similarity index 95% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByAuthorsTest.kt rename to commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByAuthorsTest.kt index 2b5a7e6d29..e69c49e62b 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/subassemblies/FilterRelayGroupsByAuthorsTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/FilterRelayGroupsByAuthorsTest.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer @@ -28,10 +28,10 @@ import com.vitorpamplona.quartz.nip29RelayGroups.GroupId import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNull +import kotlin.test.assertTrue /** * The discovery-feed augmentation that surfaces groups your follows are in. A relay-signed 39000 means a diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupFilterBuildersTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuildersTest.kt similarity index 93% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupFilterBuildersTest.kt rename to commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuildersTest.kt index cfeec285ec..1f2dd0b17c 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupFilterBuildersTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuildersTest.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource +package com.vitorpamplona.amethyst.commons.relayClient.channel.relayGroup import com.vitorpamplona.quartz.buzz.forum.ForumCommentEvent import com.vitorpamplona.quartz.buzz.forum.ForumPostEvent @@ -38,11 +38,11 @@ import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.GroupTag import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nipC7Chats.ChatEvent -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNull +import kotlin.test.assertTrue /** * Pins the exact REQ each NIP-29 data source puts on the wire (kinds, `#d`/`#h` scope, per-relay @@ -82,7 +82,7 @@ class RelayGroupFilterBuildersTest { assertEquals(listOf(RELAY_GROUP_METADATA_KINDS, RELAY_GROUP_PIN_KINDS), a.map { it.filter.kinds }) a.forEach { assertEquals(setOf("g1", "g2"), it.filter.tags!!["d"]!!.toSet()) - assertNull("state is #d-scoped, never #h", it.filter.tags!!["h"]) + assertNull(it.filter.tags!!["h"], "state is #d-scoped, never #h") } val b = filters.filter { it.relay == relayB } @@ -100,8 +100,8 @@ class RelayGroupFilterBuildersTest { buildRelayGroupStateFilters(joined) { null }.forEach { f -> val kinds = f.filter.kinds!! assertFalse( - "39005 must not share a filter with the 39000-39003 metadata block: $kinds", kinds.contains(GroupPinnedEvent.KIND) && kinds.any { it in RELAY_GROUP_METADATA_KINDS }, + "39005 must not share a filter with the 39000-39003 metadata block: $kinds", ) } } @@ -125,7 +125,7 @@ class RelayGroupFilterBuildersTest { assertEquals(timelineKinds + BUZZ_RELAY_GROUP_TIMELINE_EXTRA_KINDS, filter.filter.kinds) assertEquals(listOf("g1"), filter.filter.tags!!["h"]) assertEquals(999L, filter.filter.since) - assertNull("a time-floored tail must NOT cap by count", filter.filter.limit) + assertNull(filter.filter.limit, "a time-floored tail must NOT cap by count") assertNull(filter.filter.until) } @@ -141,7 +141,7 @@ class RelayGroupFilterBuildersTest { joined.forEach { tag -> val relay = RelayUrlNormalizer.normalizeOrNull(tag.relayUrl)!! val values = buildRelayGroupJoinedChatTailFilter(GroupId(tag.groupId, relay), 1L).filter.tags!!["h"]!! - assertEquals("a multi-value #h makes buzz register the sub as global and stop live delivery", 1, values.size) + assertEquals(1, values.size, "a multi-value #h makes buzz register the sub as global and stop live delivery") assertEquals(tag.groupId, values.single()) } } @@ -160,7 +160,7 @@ class RelayGroupFilterBuildersTest { assertEquals(relayA, filter.relay) assertEquals(listOf("g1"), filter.filter.tags!!["h"]) assertEquals(1, filter.filter.limit) - assertNull("a cold start must reach back past any window to fill the row", filter.filter.since) + assertNull(filter.filter.since, "a cold start must reach back past any window to fill the row") assertNull(filter.filter.until) } @@ -201,7 +201,7 @@ class RelayGroupFilterBuildersTest { @Test fun `aux kinds are not in the timeline set the history pager pages over`() { RELAY_GROUP_AUX_KINDS.forEach { - assertFalse("aux kind $it must not consume history-page limit", it in RELAY_GROUP_ALL_TIMELINE_KINDS) + assertFalse(it in RELAY_GROUP_ALL_TIMELINE_KINDS, "aux kind $it must not consume history-page limit") } } @@ -233,8 +233,8 @@ class RelayGroupFilterBuildersTest { assertEquals(relayA, f.relay) assertEquals(200L, f.filter.until) assertEquals(50, f.filter.limit) - assertNull("history must be all-authors so it re-materializes my own messages too", f.filter.authors) - assertNull("backward paging is until-anchored, not since", f.filter.since) + assertNull(f.filter.authors, "history must be all-authors so it re-materializes my own messages too") + assertNull(f.filter.since, "backward paging is until-anchored, not since") assertEquals(listOf("g1"), f.filter.tags!!["h"]) } @@ -267,7 +267,7 @@ class RelayGroupFilterBuildersTest { assertEquals(300L, f.filter.until) assertEquals(40, f.filter.limit) assertEquals(listOf("g1"), f.filter.tags!!["h"]) - assertNull("backward paging is until-anchored, not since", f.filter.since) + assertNull(f.filter.since, "backward paging is until-anchored, not since") assertNull(f.filter.authors) } @@ -285,7 +285,7 @@ class RelayGroupFilterBuildersTest { assertEquals(RELAY_GROUP_DIRECTORY_KINDS, f.filter.kinds) assertEquals(RELAY_GROUP_DIRECTORY_LIMIT, f.filter.limit) assertEquals(42L, f.filter.since) - assertNull("the directory lists every group, so it carries no d/h scope", f.filter.tags) + assertNull(f.filter.tags, "the directory lists every group, so it carries no d/h scope") assertNull(f.filter.until) assertNull(f.filter.authors) } @@ -296,7 +296,7 @@ class RelayGroupFilterBuildersTest { listOf(GroupMetadataEvent.KIND, GroupAdminsEvent.KIND, GroupMembersEvent.KIND, SupportedRolesEvent.KIND), RELAY_GROUP_DIRECTORY_KINDS, ) - assertFalse("the directory doesn't fetch each group's pins", RELAY_GROUP_DIRECTORY_KINDS.contains(GroupPinnedEvent.KIND)) + assertFalse(RELAY_GROUP_DIRECTORY_KINDS.contains(GroupPinnedEvent.KIND), "the directory doesn't fetch each group's pins") // The always-on state set DOES carry pins — the two kind sets must not be conflated. assertTrue(RELAY_GROUP_STATE_KINDS.contains(GroupPinnedEvent.KIND)) } @@ -334,8 +334,8 @@ class RelayGroupFilterBuildersTest { assertEquals(firstLoad.size, afterEose.size) firstLoad.zip(afterEose).forEach { (old, new) -> assertFalse( - "adding a since once EOSE lands is a since-only change → no replay on reconnect", FiltersChanged.needsToResendRequest(old, new), + "adding a since once EOSE lands is a since-only change → no replay on reconnect", ) } } @@ -347,8 +347,8 @@ class RelayGroupFilterBuildersTest { val later = groups.map { buildRelayGroupJoinedChatTailFilter(it, 2_000L).filter } // recentBoundary() crept forward earlier.zip(later).forEach { (old, new) -> assertFalse( - "a forward recent-tail floor bump is since-only → reconnect re-REQs the tail, not a full page", FiltersChanged.needsToResendRequest(old, new), + "a forward recent-tail floor bump is since-only → reconnect re-REQs the tail, not a full page", ) } } @@ -358,8 +358,8 @@ class RelayGroupFilterBuildersTest { val page1 = buildRelayGroupHistoryFilters(g1OnA, listOf(relayA), { 300L }, 50).single().filter val page2 = buildRelayGroupHistoryFilters(g1OnA, listOf(relayA), { 200L }, 50).single().filter assertTrue( - "each backward page moves until, which is genuinely new data and MUST re-REQ", FiltersChanged.needsToResendRequest(page1, page2), + "each backward page moves until, which is genuinely new data and MUST re-REQ", ) } } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/MergeFilterTagsTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MergeFilterTagsTest.kt similarity index 93% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/MergeFilterTagsTest.kt rename to commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MergeFilterTagsTest.kt index 36f34e1a39..50e05a805c 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/datasource/subassemblies/MergeFilterTagsTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/podcasts/MergeFilterTagsTest.kt @@ -18,12 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.podcasts.datasource.subassemblies +package com.vitorpamplona.amethyst.commons.relayClient.podcasts import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull -import org.junit.Test +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNull class MergeFilterTagsTest { @Test diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/FilterPostsByUrlTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/FilterPostsByUrlTest.kt similarity index 88% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/FilterPostsByUrlTest.kt rename to commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/FilterPostsByUrlTest.kt index 3829561737..88382acfc2 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/url/datasource/FilterPostsByUrlTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/url/FilterPostsByUrlTest.kt @@ -18,13 +18,13 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.url.datasource +package com.vitorpamplona.amethyst.commons.relayClient.url -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip22Comments.CommentKinds +import com.vitorpamplona.amethyst.commons.relayClient.nip22Comments.CommentKinds import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue class FilterPostsByUrlTest { @Test diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/ui/note/StubCache.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/ui/note/StubCache.kt index b8cfc4611f..4785fd6f75 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/ui/note/StubCache.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/ui/note/StubCache.kt @@ -68,5 +68,7 @@ internal class StubCache( override fun getOrCreateUser(pubkey: HexKey): User? = users[pubkey] + override fun consumeEmbedded(event: Event) = Unit + override fun justConsumeMyOwnEvent(event: Event): Boolean = false } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/EventFinderFilterAssemblyTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/EventFinderFilterAssemblyTest.kt index 7c2e9f2f62..0447b7bee3 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/EventFinderFilterAssemblyTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/EventFinderFilterAssemblyTest.kt @@ -155,6 +155,8 @@ class EventFinderFilterAssemblyTest { override fun getOrCreateUser(pubkey: HexKey): User? = null + override fun consumeEmbedded(event: Event) = Unit + override fun justConsumeMyOwnEvent(event: Event): Boolean = false } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt index 31ea0a5ca9..da14a783f0 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt @@ -1029,6 +1029,10 @@ class DesktopLocalCache : ICacheProvider { AddressableNote(address) } + override fun consumeEmbedded(event: Event) { + consume(event, null) + } + // ----- Channel operations ----- override fun getAnyChannel(note: Note): Channel? {