diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 4f52e43d7..fe977c64b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.amethyst.commons.model.nip38UserStatuses.UserStatusActi import com.vitorpamplona.amethyst.commons.model.nip56Reports.ReportAction import com.vitorpamplona.amethyst.commons.richtext.RichTextParser import com.vitorpamplona.amethyst.logTime -import com.vitorpamplona.amethyst.model.dvms.FavoriteDvmOrchestrator +import com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsOrchestrator import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListDecryptionCache import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState import com.vitorpamplona.amethyst.model.localRelays.ForwardKind0ToLocalRelayState @@ -67,8 +67,8 @@ import com.vitorpamplona.amethyst.model.nip51Lists.blockedRelays.BlockedRelayLis import com.vitorpamplona.amethyst.model.nip51Lists.blockedRelays.BlockedRelayListState import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListDecryptionCache import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListState -import com.vitorpamplona.amethyst.model.nip51Lists.favoriteDvmLists.FavoriteDvmListDecryptionCache -import com.vitorpamplona.amethyst.model.nip51Lists.favoriteDvmLists.FavoriteDvmListState +import com.vitorpamplona.amethyst.model.nip51Lists.favoriteAlgoFeedsLists.FavoriteAlgoFeedsListDecryptionCache +import com.vitorpamplona.amethyst.model.nip51Lists.favoriteAlgoFeedsLists.FavoriteAlgoFeedsListState import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListDecryptionCache import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListDecryptionCache @@ -327,9 +327,9 @@ class Account( val hashtagListDecryptionCache = HashtagListDecryptionCache(signer) val hashtagList = HashtagListState(signer, cache, hashtagListDecryptionCache, scope, settings) - val favoriteDvmListDecryptionCache = FavoriteDvmListDecryptionCache(signer) - val favoriteDvmList = FavoriteDvmListState(signer, cache, favoriteDvmListDecryptionCache, scope, settings) - val favoriteDvmOrchestrator = FavoriteDvmOrchestrator(this, scope) + val favoriteAlgoFeedsListDecryptionCache = FavoriteAlgoFeedsListDecryptionCache(signer) + val favoriteAlgoFeedsList = FavoriteAlgoFeedsListState(signer, cache, favoriteAlgoFeedsListDecryptionCache, scope, settings) + val favoriteAlgoFeedsOrchestrator = FavoriteAlgoFeedsOrchestrator(this, scope) val geohashListDecryptionCache = GeohashListDecryptionCache(signer) val geohashList = GeohashListState(signer, cache, geohashListDecryptionCache, scope, settings) @@ -426,8 +426,8 @@ class Account( caches = feedDecryptionCaches, signer = signer, scope = scope, - favoriteDvmOrchestrator = favoriteDvmOrchestrator, - favoriteDvmAddresses = favoriteDvmList.flow, + favoriteAlgoFeedsOrchestrator = favoriteAlgoFeedsOrchestrator, + favoriteAlgoFeedAddresses = favoriteAlgoFeedsList.flow, ).flow // App-ready Feeds @@ -1023,11 +1023,11 @@ class Account( suspend fun unfollowHashtag(tag: String) = sendMyPublicAndPrivateOutbox(hashtagList.unfollow(tag)) - suspend fun followFavoriteDvm(dvm: AddressBookmark) = sendMyPublicAndPrivateOutbox(favoriteDvmList.follow(dvm)) + suspend fun followFavoriteAlgoFeed(dvm: AddressBookmark) = sendMyPublicAndPrivateOutbox(favoriteAlgoFeedsList.follow(dvm)) - suspend fun unfollowFavoriteDvm(dvm: Address) = sendMyPublicAndPrivateOutbox(favoriteDvmList.unfollow(dvm)) + suspend fun unfollowFavoriteAlgoFeed(dvm: Address) = sendMyPublicAndPrivateOutbox(favoriteAlgoFeedsList.unfollow(dvm)) - fun isFavoriteDvm(dvm: Address): Boolean = favoriteDvmList.flow.value.contains(dvm) + fun isFavoriteAlgoFeed(dvm: Address): Boolean = favoriteAlgoFeedsList.flow.value.contains(dvm) suspend fun followGeohash(geohash: String) = sendMyPublicAndPrivateOutbox(geohashList.follow(geohash)) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt index 2a5f6b681..4b7319d04 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt @@ -157,11 +157,11 @@ sealed class TopFilter( ) : TopFilter("Relay/$url") @Serializable - class FavoriteDvm( + class FavoriteAlgoFeed( val address: Address, - ) : TopFilter("FavoriteDvm/${address.toValue()}") + ) : TopFilter("FavoriteAlgoFeed/${address.toValue()}") - @Serializable object AllFavoriteDvms : TopFilter(" All Favourite DVMs ") + @Serializable object AllFavoriteAlgoFeeds : TopFilter(" All Favourite DVMs ") } @Stable @@ -203,7 +203,7 @@ class AccountSettings( var backupChannelList: ChannelListEvent? = null, var backupCommunityList: CommunityListEvent? = null, var backupHashtagList: HashtagListEvent? = null, - var backupFavoriteDvmList: FavoriteAlgoFeedsListEvent? = null, + var backupFavoriteAlgoFeedsList: FavoriteAlgoFeedsListEvent? = null, var backupGeohashList: GeohashListEvent? = null, var backupEphemeralChatList: EphemeralChatListEvent? = null, var backupTrustProviderList: TrustProviderListEvent? = null, @@ -727,12 +727,12 @@ class AccountSettings( } } - fun updateFavoriteDvmListTo(newFavoriteDvmList: FavoriteAlgoFeedsListEvent?) { + fun updateFavoriteAlgoFeedsListTo(newFavoriteDvmList: FavoriteAlgoFeedsListEvent?) { if (newFavoriteDvmList == null || newFavoriteDvmList.tags.isEmpty()) return // Events might be different objects, we have to compare their ids. - if (backupFavoriteDvmList?.id != newFavoriteDvmList.id) { - backupFavoriteDvmList = newFavoriteDvmList + if (backupFavoriteAlgoFeedsList?.id != newFavoriteDvmList.id) { + backupFavoriteAlgoFeedsList = newFavoriteDvmList saveAccountSettings() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/dvms/FavoriteDvmOrchestrator.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/algoFeeds/FavoriteAlgoFeedsOrchestrator.kt similarity index 86% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/dvms/FavoriteDvmOrchestrator.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/algoFeeds/FavoriteAlgoFeedsOrchestrator.kt index 860cdfd0e..0496ad62d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/dvms/FavoriteDvmOrchestrator.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/algoFeeds/FavoriteAlgoFeedsOrchestrator.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.model.dvms +package com.vitorpamplona.amethyst.model.algoFeeds import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.Address @@ -45,7 +45,7 @@ import kotlinx.coroutines.sync.withLock private const val RESPONSE_TIMEOUT_MS = 20_000L /** - * Immutable snapshot of a favorite DVM's current request/response state. + * Immutable snapshot of a favorite algo feed's current request/response state. * * - [requestId] is the id of the most recently published kind-5300 request. * - [responseRelays] is the relay set the kind-5300 was sent to — the same set on @@ -55,7 +55,7 @@ private const val RESPONSE_TIMEOUT_MS = 20_000L * - [latestStatus] is the latest kind-7000 status event (processing, payment-required, error, …). * - [errorMessage] captures any client-side failure while publishing the request. */ -data class FavoriteDvmSnapshot( +data class FavoriteAlgoFeedsSnapshot( val requestId: HexKey? = null, val responseRelays: Set = emptySet(), val ids: Set = emptySet(), @@ -65,7 +65,7 @@ data class FavoriteDvmSnapshot( ) /** - * Manages the NIP-90 content-discovery RPC cycle for each favorite DVM the user + * Manages the NIP-90 content-discovery RPC cycle for each favorite algo feed the user * pins to the top-nav. * * The orchestrator is lazy: it starts a request/response cycle the first time any @@ -75,50 +75,50 @@ data class FavoriteDvmSnapshot( * * This class does not own the relay subscriptions that fetch DVM responses and * matching notes. Those are issued by `HomeOutboxEventsEoseManager` while the - * user has a `TopFilter.FavoriteDvm` selected. The orchestrator merely observes + * user has a `TopFilter.FavoriteAlgoFeed` selected. The orchestrator merely observes * what the relays deliver into `LocalCache`. */ -class FavoriteDvmOrchestrator( +class FavoriteAlgoFeedsOrchestrator( val account: Account, val scope: CoroutineScope, ) { - private val flows = mutableMapOf>() + private val flows = mutableMapOf>() private val jobs = mutableMapOf() private val mutex = Mutex() - fun observe(dvmAddress: Address): StateFlow { - flows[dvmAddress]?.let { return it.asStateFlow() } + fun observe(feedAddress: Address): StateFlow { + flows[feedAddress]?.let { return it.asStateFlow() } - val seed = MutableStateFlow(FavoriteDvmSnapshot()) - flows[dvmAddress] = seed - scope.launch { startFor(dvmAddress, seed) } + val seed = MutableStateFlow(FavoriteAlgoFeedsSnapshot()) + flows[feedAddress] = seed + scope.launch { startFor(feedAddress, seed) } return seed.asStateFlow() } - fun refresh(dvmAddress: Address) { - val seed = flows[dvmAddress] ?: return + fun refresh(feedAddress: Address) { + val seed = flows[feedAddress] ?: return scope.launch { mutex.withLock { - jobs.remove(dvmAddress)?.cancel() + jobs.remove(feedAddress)?.cancel() } - startFor(dvmAddress, seed) + startFor(feedAddress, seed) } } - fun stop(dvmAddress: Address) { + fun stop(feedAddress: Address) { scope.launch { mutex.withLock { - jobs.remove(dvmAddress)?.cancel() - flows.remove(dvmAddress) + jobs.remove(feedAddress)?.cancel() + flows.remove(feedAddress) } } } private suspend fun startFor( - dvmAddress: Address, - seed: MutableStateFlow, + feedAddress: Address, + seed: MutableStateFlow, ) { - val user = account.cache.checkGetOrCreateUser(dvmAddress.pubKeyHex) ?: return + val user = account.cache.checkGetOrCreateUser(feedAddress.pubKeyHex) ?: return val job = scope.launch(Dispatchers.IO) { try { @@ -188,12 +188,12 @@ class FavoriteDvmOrchestrator( } } catch (e: Exception) { if (e is CancellationException) throw e - Log.w("FavoriteDvmOrchestrator", "Failed to start DVM request: ${e.message}", e) + Log.w("FavoriteAlgoFeedsOrchestrator", "Failed to start DVM request: ${e.message}", e) seed.update { it.copy(errorMessage = e.message ?: "Unknown error") } } } - mutex.withLock { jobs[dvmAddress] = job } + mutex.withLock { jobs[feedAddress] = job } } private fun splitInnerTags(innerTags: List): Pair, Set> { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteDvmLists/FavoriteDvmListDecryptionCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteAlgoFeedsLists/FavoriteAlgoFeedsListDecryptionCache.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteDvmLists/FavoriteDvmListDecryptionCache.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteAlgoFeedsLists/FavoriteAlgoFeedsListDecryptionCache.kt index fef666385..03b3f8536 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteDvmLists/FavoriteDvmListDecryptionCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteAlgoFeedsLists/FavoriteAlgoFeedsListDecryptionCache.kt @@ -18,19 +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.model.nip51Lists.favoriteDvmLists +package com.vitorpamplona.amethyst.model.nip51Lists.favoriteAlgoFeedsLists import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.favoriteAlgoFeedsSet -class FavoriteDvmListDecryptionCache( +class FavoriteAlgoFeedsListDecryptionCache( val signer: NostrSigner, ) { val cachedPrivateLists = PrivateTagArrayEventCache(signer) - fun cachedFavoriteDvms(event: FavoriteAlgoFeedsListEvent) = cachedPrivateLists.mergeTagListPrecached(event).favoriteAlgoFeedsSet() + fun cachedFavoriteAlgoFeeds(event: FavoriteAlgoFeedsListEvent) = cachedPrivateLists.mergeTagListPrecached(event).favoriteAlgoFeedsSet() - suspend fun favoriteDvms(event: FavoriteAlgoFeedsListEvent) = cachedPrivateLists.mergeTagList(event).favoriteAlgoFeedsSet() + suspend fun favoriteAlgoFeeds(event: FavoriteAlgoFeedsListEvent) = cachedPrivateLists.mergeTagList(event).favoriteAlgoFeedsSet() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteDvmLists/FavoriteDvmListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteAlgoFeedsLists/FavoriteAlgoFeedsListState.kt similarity index 77% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteDvmLists/FavoriteDvmListState.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteAlgoFeedsLists/FavoriteAlgoFeedsListState.kt index 6181d8b02..b39d78e80 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteDvmLists/FavoriteDvmListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteAlgoFeedsLists/FavoriteAlgoFeedsListState.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.model.nip51Lists.favoriteDvmLists +package com.vitorpamplona.amethyst.model.nip51Lists.favoriteAlgoFeedsLists import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.amethyst.model.AddressableNote @@ -43,34 +43,34 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.transformLatest import kotlinx.coroutines.launch -class FavoriteDvmListState( +class FavoriteAlgoFeedsListState( val signer: NostrSigner, val cache: LocalCache, - val decryptionCache: FavoriteDvmListDecryptionCache, + val decryptionCache: FavoriteAlgoFeedsListDecryptionCache, val scope: CoroutineScope, val settings: AccountSettings, ) { // Creates a long-term reference for this note so that the GC doesn't collect the note itself - val favoriteDvmListNote = cache.getOrCreateAddressableNote(getFavoriteDvmListAddress()) + val favoriteAlgoFeedsListNote = cache.getOrCreateAddressableNote(getFavoriteAlgoFeedsListAddress()) - fun getFavoriteDvmListAddress() = FavoriteAlgoFeedsListEvent.createAddress(signer.pubKey) + fun getFavoriteAlgoFeedsListAddress() = FavoriteAlgoFeedsListEvent.createAddress(signer.pubKey) - fun getFavoriteDvmListFlow(): StateFlow = favoriteDvmListNote.flow().metadata.stateFlow + fun getFavoriteAlgoFeedsListFlow(): StateFlow = favoriteAlgoFeedsListNote.flow().metadata.stateFlow - fun getFavoriteDvmList(): FavoriteAlgoFeedsListEvent? = favoriteDvmListNote.event as? FavoriteAlgoFeedsListEvent + fun getFavoriteAlgoFeedsList(): FavoriteAlgoFeedsListEvent? = favoriteAlgoFeedsListNote.event as? FavoriteAlgoFeedsListEvent - suspend fun favoriteDvmListWithBackup(note: Note): Set
{ - val event = note.event as? FavoriteAlgoFeedsListEvent ?: settings.backupFavoriteDvmList - return event?.let { decryptionCache.favoriteDvms(it) } ?: emptySet() + suspend fun favoriteAlgoFeedsListWithBackup(note: Note): Set
{ + val event = note.event as? FavoriteAlgoFeedsListEvent ?: settings.backupFavoriteAlgoFeedsList + return event?.let { decryptionCache.favoriteAlgoFeeds(it) } ?: emptySet() } @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow> = - getFavoriteDvmListFlow() + getFavoriteAlgoFeedsListFlow() .transformLatest { noteState -> - emit(favoriteDvmListWithBackup(noteState.note)) + emit(favoriteAlgoFeedsListWithBackup(noteState.note)) }.onStart { - emit(favoriteDvmListWithBackup(favoriteDvmListNote)) + emit(favoriteAlgoFeedsListWithBackup(favoriteAlgoFeedsListNote)) }.flowOn(Dispatchers.IO) .stateIn( scope, @@ -93,7 +93,7 @@ class FavoriteDvmListState( ) suspend fun follow(dvm: AddressBookmark): FavoriteAlgoFeedsListEvent { - val list = getFavoriteDvmList() + val list = getFavoriteAlgoFeedsList() return if (list == null) { FavoriteAlgoFeedsListEvent.create(dvm, false, signer) } else { @@ -102,12 +102,12 @@ class FavoriteDvmListState( } suspend fun unfollow(dvm: Address): FavoriteAlgoFeedsListEvent? { - val list = getFavoriteDvmList() ?: return null + val list = getFavoriteAlgoFeedsList() ?: return null return FavoriteAlgoFeedsListEvent.remove(list, dvm, signer) } init { - settings.backupFavoriteDvmList?.let { event -> + settings.backupFavoriteAlgoFeedsList?.let { event -> Log.d("AccountRegisterObservers") { "Loading saved Favorite DVM list ${event.toJson()}" } @OptIn(DelicateCoroutinesApi::class) scope.launch(Dispatchers.IO) { @@ -117,10 +117,10 @@ class FavoriteDvmListState( scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Favorite DVM List Collector Start") - getFavoriteDvmListFlow().collect { + getFavoriteAlgoFeedsListFlow().collect { Log.d("AccountRegisterObservers") { "Favorite DVM List for ${signer.pubKey}" } (it.note.event as? FavoriteAlgoFeedsListEvent)?.let { - settings.updateFavoriteDvmListTo(it) + settings.updateFavoriteAlgoFeedsListTo(it) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt index be72d1b26..d8269aa43 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.model.topNavFeeds import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.TopFilter -import com.vitorpamplona.amethyst.model.dvms.FavoriteDvmOrchestrator +import com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsOrchestrator import com.vitorpamplona.amethyst.model.nip02FollowLists.Kind3FollowListState import com.vitorpamplona.amethyst.model.serverList.MergedFollowListsState import com.vitorpamplona.amethyst.model.topNavFeeds.allFollows.AllFollowsFeedFlow @@ -31,8 +31,8 @@ import com.vitorpamplona.amethyst.model.topNavFeeds.allUserFollows.Kind3UserFoll import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.AroundMeFeedFlow import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.GeohashFeedFlow import com.vitorpamplona.amethyst.model.topNavFeeds.chess.ChessFeedFlow -import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.AllFavoriteDvmsFeedFlow -import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmFeedFlow +import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.AllFavoriteAlgoFeedsFlow +import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedFlow import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalFeedFlow import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagFeedFlow import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.NoteFeedFlow @@ -66,8 +66,8 @@ class FeedTopNavFilterState( val caches: FeedDecryptionCaches, val signer: NostrSigner, val scope: CoroutineScope, - val favoriteDvmOrchestrator: FavoriteDvmOrchestrator, - val favoriteDvmAddresses: StateFlow>, + val favoriteAlgoFeedsOrchestrator: FavoriteAlgoFeedsOrchestrator, + val favoriteAlgoFeedAddresses: StateFlow>, ) { fun loadFlowsFor(listName: TopFilter): IFeedFlowsType = when (listName) { @@ -149,19 +149,19 @@ class FeedTopNavFilterState( RelayFeedFlow(listName.url.normalizeRelayUrl()) } - is TopFilter.FavoriteDvm -> { - FavoriteDvmFeedFlow( - dvmAddress = listName.address, - orchestrator = favoriteDvmOrchestrator, + is TopFilter.FavoriteAlgoFeed -> { + FavoriteAlgoFeedFlow( + feedAddress = listName.address, + orchestrator = favoriteAlgoFeedsOrchestrator, outboxRelays = followsRelays, proxyRelays = proxyRelays, ) } - TopFilter.AllFavoriteDvms -> { - AllFavoriteDvmsFeedFlow( - favoriteDvmAddresses = favoriteDvmAddresses, - orchestrator = favoriteDvmOrchestrator, + TopFilter.AllFavoriteAlgoFeeds -> { + AllFavoriteAlgoFeedsFlow( + favoriteAlgoFeedAddresses = favoriteAlgoFeedAddresses, + orchestrator = favoriteAlgoFeedsOrchestrator, outboxRelays = followsRelays, proxyRelays = proxyRelays, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/AllFavoriteDvmsFeedFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/AllFavoriteAlgoFeedsFlow.kt similarity index 80% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/AllFavoriteDvmsFeedFlow.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/AllFavoriteAlgoFeedsFlow.kt index c35c2ba72..f23930722 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/AllFavoriteDvmsFeedFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/AllFavoriteAlgoFeedsFlow.kt @@ -18,10 +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.model.topNavFeeds.favoriteDvm +package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds -import com.vitorpamplona.amethyst.model.dvms.FavoriteDvmOrchestrator -import com.vitorpamplona.amethyst.model.dvms.FavoriteDvmSnapshot +import com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsOrchestrator +import com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsSnapshot import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedFlowsType import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavFilter import com.vitorpamplona.quartz.nip01Core.core.Address @@ -35,12 +35,12 @@ import kotlinx.coroutines.flow.flatMapLatest /** * Feed flow that merges snapshots from every currently-favorited DVM into a - * single [AllFavoriteDvmsTopNavFilter]. Re-wires subscriptions whenever the + * single [AllFavoriteAlgoFeedsTopNavFilter]. Re-wires subscriptions whenever the * favorite set changes. */ -class AllFavoriteDvmsFeedFlow( - val favoriteDvmAddresses: StateFlow>, - val orchestrator: FavoriteDvmOrchestrator, +class AllFavoriteAlgoFeedsFlow( + val favoriteAlgoFeedAddresses: StateFlow>, + val orchestrator: FavoriteAlgoFeedsOrchestrator, val outboxRelays: StateFlow>, val proxyRelays: StateFlow>, ) : IFeedFlowsType { @@ -50,9 +50,9 @@ class AllFavoriteDvmsFeedFlow( ): Set = if (proxy.isNotEmpty()) proxy else outbox private fun merge( - snapshots: List, + snapshots: List, contentRelays: Set, - ): AllFavoriteDvmsTopNavFilter { + ): AllFavoriteAlgoFeedsTopNavFilter { val ids = mutableSetOf() val addresses = mutableSetOf() val listen = mutableSetOf() @@ -63,7 +63,7 @@ class AllFavoriteDvmsFeedFlow( listen += snap.responseRelays snap.requestId?.let { requestIds += it } } - return AllFavoriteDvmsTopNavFilter( + return AllFavoriteAlgoFeedsTopNavFilter( acceptedIds = ids, acceptedAddresses = addresses, contentRelays = contentRelays, @@ -72,8 +72,8 @@ class AllFavoriteDvmsFeedFlow( ) } - private fun emptyFilter(contentRelays: Set): AllFavoriteDvmsTopNavFilter = - AllFavoriteDvmsTopNavFilter( + private fun emptyFilter(contentRelays: Set): AllFavoriteAlgoFeedsTopNavFilter = + AllFavoriteAlgoFeedsTopNavFilter( acceptedIds = emptySet(), acceptedAddresses = emptySet(), contentRelays = contentRelays, @@ -83,13 +83,13 @@ class AllFavoriteDvmsFeedFlow( @OptIn(ExperimentalCoroutinesApi::class) override fun flow(): Flow = - favoriteDvmAddresses.flatMapLatest { addresses -> + favoriteAlgoFeedAddresses.flatMapLatest { addresses -> if (addresses.isEmpty()) { combine(outboxRelays, proxyRelays) { outbox, proxy -> emptyFilter(resolveContentRelays(outbox, proxy)) } } else { - val snapshotFlows: List> = addresses.map { orchestrator.observe(it) } + val snapshotFlows: List> = addresses.map { orchestrator.observe(it) } combine(snapshotFlows) { it.toList() } .let { merged -> combine(merged, outboxRelays, proxyRelays) { snaps, outbox, proxy -> @@ -99,9 +99,9 @@ class AllFavoriteDvmsFeedFlow( } } - override fun startValue(): AllFavoriteDvmsTopNavFilter { + override fun startValue(): AllFavoriteAlgoFeedsTopNavFilter { val contentRelays = resolveContentRelays(outboxRelays.value, proxyRelays.value) - val addresses = favoriteDvmAddresses.value + val addresses = favoriteAlgoFeedAddresses.value return if (addresses.isEmpty()) { emptyFilter(contentRelays) } else { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/AllFavoriteDvmsTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/AllFavoriteAlgoFeedsTopNavFilter.kt similarity index 85% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/AllFavoriteDvmsTopNavFilter.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/AllFavoriteAlgoFeedsTopNavFilter.kt index 36e7e6b6f..eba50b6bc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/AllFavoriteDvmsTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/AllFavoriteAlgoFeedsTopNavFilter.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.model.topNavFeeds.favoriteDvm +package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds import androidx.compose.runtime.Immutable import com.vitorpamplona.amethyst.model.LocalCache @@ -32,12 +32,12 @@ import kotlinx.coroutines.flow.MutableStateFlow /** * Top-nav filter that unions the latest kind-6300 responses from every currently - * favorited DVM. Behaves like [FavoriteDvmTopNavFilter] (pure membership check + * favorited DVM. Behaves like [FavoriteAlgoFeedTopNavFilter] (pure membership check * against a snapshot), but the accepted set is the union across N DVMs and the * request-id list carries one entry per DVM for the relay-listen subscription. */ @Immutable -class AllFavoriteDvmsTopNavFilter( +class AllFavoriteAlgoFeedsTopNavFilter( val acceptedIds: Set, val acceptedAddresses: Set, val contentRelays: Set, @@ -50,13 +50,13 @@ class AllFavoriteDvmsTopNavFilter( noteEvent.id in acceptedIds || (noteEvent is AddressableEvent && noteEvent.addressTag() in acceptedAddresses) - override fun toPerRelayFlow(cache: LocalCache): Flow = MutableStateFlow(startValue(cache)) + override fun toPerRelayFlow(cache: LocalCache): Flow = MutableStateFlow(startValue(cache)) - override fun startValue(cache: LocalCache): FavoriteDvmTopNavPerRelayFilterSet = - FavoriteDvmTopNavPerRelayFilterSet( + override fun startValue(cache: LocalCache): FavoriteAlgoFeedTopNavPerRelayFilterSet = + FavoriteAlgoFeedTopNavPerRelayFilterSet( contentFetches = contentRelays.associateWith { - FavoriteDvmTopNavPerRelayFilter( + FavoriteAlgoFeedTopNavPerRelayFilter( ids = acceptedIds, addresses = acceptedAddresses, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmFeedFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedFlow.kt similarity index 79% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmFeedFlow.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedFlow.kt index 04d35e0d6..e17accd43 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmFeedFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedFlow.kt @@ -18,9 +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.model.topNavFeeds.favoriteDvm +package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds -import com.vitorpamplona.amethyst.model.dvms.FavoriteDvmOrchestrator +import com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsOrchestrator import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedFlowsType import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavFilter import com.vitorpamplona.quartz.nip01Core.core.Address @@ -30,9 +30,9 @@ import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine -class FavoriteDvmFeedFlow( - val dvmAddress: Address, - val orchestrator: FavoriteDvmOrchestrator, +class FavoriteAlgoFeedFlow( + val feedAddress: Address, + val orchestrator: FavoriteAlgoFeedsOrchestrator, val outboxRelays: StateFlow>, val proxyRelays: StateFlow>, ) : IFeedFlowsType { @@ -42,10 +42,10 @@ class FavoriteDvmFeedFlow( ): Set = if (proxy.isNotEmpty()) proxy else outbox private fun buildFilter( - snapshot: com.vitorpamplona.amethyst.model.dvms.FavoriteDvmSnapshot, + snapshot: com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsSnapshot, contentRelays: Set, - ) = FavoriteDvmTopNavFilter( - dvmAddress = dvmAddress, + ) = FavoriteAlgoFeedTopNavFilter( + feedAddress = feedAddress, acceptedIds = snapshot.ids, acceptedAddresses = snapshot.addresses, contentRelays = contentRelays, @@ -54,13 +54,13 @@ class FavoriteDvmFeedFlow( ) override fun flow(): Flow = - combine(orchestrator.observe(dvmAddress), outboxRelays, proxyRelays) { snap, outbox, proxy -> + combine(orchestrator.observe(feedAddress), outboxRelays, proxyRelays) { snap, outbox, proxy -> buildFilter(snap, resolveRelays(outbox, proxy)) } - override fun startValue(): FavoriteDvmTopNavFilter = + override fun startValue(): FavoriteAlgoFeedTopNavFilter = buildFilter( - snapshot = orchestrator.observe(dvmAddress).value, + snapshot = orchestrator.observe(feedAddress).value, contentRelays = resolveRelays(outboxRelays.value, proxyRelays.value), ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilter.kt similarity index 84% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavFilter.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilter.kt index 9534bc1c8..6cd70135c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilter.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.model.topNavFeeds.favoriteDvm +package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds import androidx.compose.runtime.Immutable import com.vitorpamplona.amethyst.model.LocalCache @@ -32,15 +32,15 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow /** - * Top-nav filter backed by the latest kind-6300 response from a favorite DVM. + * Top-nav filter backed by the latest kind-6300 response from a favorite algo feed. * * The filter is a pure immutable membership check: [match] accepts a note only if the * DVM's latest response included it. When a new response arrives, a new instance is - * emitted through [FavoriteDvmFeedFlow] and replaces the active filter. + * emitted through [FavoriteAlgoFeedFlow] and replaces the active filter. */ @Immutable -class FavoriteDvmTopNavFilter( - val dvmAddress: Address, +class FavoriteAlgoFeedTopNavFilter( + val feedAddress: Address, val acceptedIds: Set, val acceptedAddresses: Set, val contentRelays: Set, @@ -53,13 +53,13 @@ class FavoriteDvmTopNavFilter( noteEvent.id in acceptedIds || (noteEvent is AddressableEvent && noteEvent.addressTag() in acceptedAddresses) - override fun toPerRelayFlow(cache: LocalCache): Flow = MutableStateFlow(startValue(cache)) + override fun toPerRelayFlow(cache: LocalCache): Flow = MutableStateFlow(startValue(cache)) - override fun startValue(cache: LocalCache): FavoriteDvmTopNavPerRelayFilterSet = - FavoriteDvmTopNavPerRelayFilterSet( + override fun startValue(cache: LocalCache): FavoriteAlgoFeedTopNavPerRelayFilterSet = + FavoriteAlgoFeedTopNavPerRelayFilterSet( contentFetches = contentRelays.associateWith { - FavoriteDvmTopNavPerRelayFilter( + FavoriteAlgoFeedTopNavPerRelayFilter( ids = acceptedIds, addresses = acceptedAddresses, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavPerRelayFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavPerRelayFilter.kt similarity index 92% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavPerRelayFilter.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavPerRelayFilter.kt index 4dcbeddaa..374f5ecf0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavPerRelayFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavPerRelayFilter.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.model.topNavFeeds.favoriteDvm +package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds import androidx.compose.runtime.Immutable import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavPerRelayFilter import com.vitorpamplona.quartz.nip01Core.core.HexKey @Immutable -class FavoriteDvmTopNavPerRelayFilter( +class FavoriteAlgoFeedTopNavPerRelayFilter( val ids: Set, val addresses: Set, ) : IFeedTopNavPerRelayFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavPerRelayFilterSet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavPerRelayFilterSet.kt similarity index 85% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavPerRelayFilterSet.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavPerRelayFilterSet.kt index 318840384..a111c9361 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavPerRelayFilterSet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavPerRelayFilterSet.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.model.topNavFeeds.favoriteDvm +package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavPerRelayFilterSet import com.vitorpamplona.quartz.nip01Core.core.HexKey @@ -32,11 +32,11 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl * - [listenRelays] — the union of DVM publish relays across all active DVMs * (where they will deliver future kind 6300 / 7000 events for their requests). * - [requestIds] — the set of currently-active kind-5300 request ids to listen - * for. A single-DVM filter carries one; the merged "All favorite DVMs" - * filter carries one per favorite DVM. + * for. A single feed carries one; the merged "All favorite algo feeds" + * filter carries one per favorite algo feed. */ -class FavoriteDvmTopNavPerRelayFilterSet( - val contentFetches: Map, +class FavoriteAlgoFeedTopNavPerRelayFilterSet( + val contentFetches: Map, val listenRelays: Set, val requestIds: Set, ) : IFeedTopNavPerRelayFilterSet diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt index 972befbcd..3ba6d22b3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt @@ -95,7 +95,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm.Long import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.NewProductScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.drafts.DraftListScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.DvmContentDiscoveryScreen -import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.favorites.FavoriteDvmListScreen +import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.favorites.FavoriteAlgoFeedsListScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.FollowPackFeedScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.GeoHashPostScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.GeoHashScreen @@ -278,7 +278,7 @@ fun BuildNavigation( composableFromEnd { RequestToVanishScreen(accountViewModel, nav) } composableFromEnd { VanishEventsScreen(accountViewModel, nav) } composableFromEndArgs { AllMediaServersScreen(accountViewModel, nav) } - composableFromEnd { FavoriteDvmListScreen(accountViewModel, nav) } + composableFromEnd { FavoriteAlgoFeedsListScreen(accountViewModel, nav) } composableFromEnd { PaymentTargetsScreen(accountViewModel, nav) } composableFromEndArgs { UpdateReactionTypeScreen(accountViewModel, nav) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt index 057a24397..70a12a0dd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt @@ -171,7 +171,7 @@ sealed class Route { @Serializable object EditMediaServers : Route() - @Serializable object EditFavoriteDvms : Route() + @Serializable object EditFavoriteAlgoFeeds : Route() @Serializable object EditPaymentTargets : Route() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt index b4cf9a719..9d01c8a12 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/topbars/FeedFilterSpinner.kt @@ -86,7 +86,7 @@ import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNo import com.vitorpamplona.amethyst.ui.components.LoadingAnimation import com.vitorpamplona.amethyst.ui.note.creators.location.LoadCityName import com.vitorpamplona.amethyst.ui.screen.CommunityName -import com.vitorpamplona.amethyst.ui.screen.FavoriteDvmName +import com.vitorpamplona.amethyst.ui.screen.FavoriteAlgoFeedName import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.GeoHashName import com.vitorpamplona.amethyst.ui.screen.HashtagName @@ -361,7 +361,7 @@ fun RenderOption( ) } - is FavoriteDvmName -> { + is FavoriteAlgoFeedName -> { val noteState by observeNote(option.note, accountViewModel) val name = (noteState.note.event as? AppDefinitionEvent) @@ -419,7 +419,7 @@ private fun groupFeedDefinitions(options: ImmutableList): Map { + is FavoriteAlgoFeedName -> { FeedGroup.DVMS } @@ -427,7 +427,7 @@ private fun groupFeedDefinitions(options: ImmutableList): Map FeedGroup.LOCATIONS is TopFilter.Global -> FeedGroup.RELAYS - is TopFilter.AllFavoriteDvms -> FeedGroup.DVMS + is TopFilter.AllFavoriteAlgoFeeds -> FeedGroup.DVMS else -> FeedGroup.FEEDS } } @@ -592,11 +592,11 @@ private fun FeedIcon( Icons.AutoMirrored.Outlined.ViewList } - is TopFilter.FavoriteDvm -> { + is TopFilter.FavoriteAlgoFeed -> { Icons.Outlined.AutoAwesome } - is TopFilter.AllFavoriteDvms -> { + is TopFilter.AllFavoriteAlgoFeeds -> { Icons.Outlined.AutoAwesome } @@ -606,7 +606,7 @@ private fun FeedIcon( is RelayName -> Icons.Outlined.Storage is CommunityName -> Icons.Outlined.Groups is PeopleListName -> Icons.AutoMirrored.Outlined.ViewList - is FavoriteDvmName -> Icons.Outlined.AutoAwesome + is FavoriteAlgoFeedName -> Icons.Outlined.AutoAwesome else -> Icons.Outlined.Person } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt index 7b65a43e1..69060103f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt @@ -97,9 +97,9 @@ class TopNavFilterState( name = ResourceName(R.string.follow_list_chess), ) - val allFavoriteDvmsFollow = + val allFavoriteAlgoFeedsFollow = FeedDefinition( - code = TopFilter.AllFavoriteDvms, + code = TopFilter.AllFavoriteAlgoFeeds, name = ResourceName(R.string.follow_list_all_favorite_dvms), ) @@ -147,7 +147,7 @@ class TopNavFilterState( geotagList: Set, communityList: List, relayList: Set, - favoriteDvmList: List, + favoriteAlgoFeedsList: List, ): List { val hashtags = hashtagList.map { @@ -181,26 +181,26 @@ class TopNavFilterState( ) } - // Favorites can only be added through FavoriteDvmToggle, which itself checks + // Favorites can only be added through FavoriteAlgoFeedToggle, which itself checks // that the AppDefinitionEvent advertises kind 5300. Don't re-check here: on // cold start the AppDefinitionEvent may not be in cache yet, and dropping - // the entry means the persisted TopFilter.FavoriteDvm can't find its chip + // the entry means the persisted TopFilter.FavoriteAlgoFeed can't find its chip // in the spinner (user sees "Select an option" while the banner fires the // RPC — the bug we had before this change). - val favoriteDvms = - favoriteDvmList.map { dvmNote -> + val favoriteAlgoFeeds = + favoriteAlgoFeedsList.map { feedNote -> FeedDefinition( - TopFilter.FavoriteDvm(dvmNote.address), - FavoriteDvmName(dvmNote), + TopFilter.FavoriteAlgoFeed(feedNote.address), + FavoriteAlgoFeedName(feedNote), ) } - // Only show the "All favorite DVMs" meta-chip when there is at least one + // Only show the "All favorite algo feeds" meta-chip when there is at least one // real favorite to merge; otherwise the chip opens to an empty feed. val allFavorites = - if (favoriteDvms.isNotEmpty()) listOf(allFavoriteDvmsFollow) else emptyList() + if (favoriteAlgoFeeds.isNotEmpty()) listOf(allFavoriteAlgoFeedsFollow) else emptyList() - return (communities + hashtags + geotags + relays + allFavorites + favoriteDvms).sortedBy { it.name.name() } + return (communities + hashtags + geotags + relays + allFavorites + favoriteAlgoFeeds).sortedBy { it.name.name() } } @OptIn(ExperimentalCoroutinesApi::class) @@ -210,7 +210,7 @@ class TopNavFilterState( account.geohashList.flow, account.communityList.flowNotes, account.relayFeedsList.flow, - account.favoriteDvmList.flowNotes, + account.favoriteAlgoFeedsList.flowNotes, ::mergeInterests, ).onStart { emit( @@ -219,7 +219,7 @@ class TopNavFilterState( account.geohashList.flow.value, account.communityList.flowNotes.value, account.relayFeedsList.flow.value, - account.favoriteDvmList.flowNotes.value, + account.favoriteAlgoFeedsList.flowNotes.value, ), ) } @@ -328,7 +328,7 @@ class CommunityName( } @Stable -class FavoriteDvmName( +class FavoriteAlgoFeedName( val note: AddressableNote, ) : Name() { override fun name(): String = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 97b01c336..e08814ee4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -1089,11 +1089,11 @@ class AccountViewModel( fun unfollowHashtag(tag: String) = launchSigner { account.unfollowHashtag(tag) } - fun followFavoriteDvm(dvm: AddressBookmark) = launchSigner { account.followFavoriteDvm(dvm) } + fun followFavoriteAlgoFeed(dvm: AddressBookmark) = launchSigner { account.followFavoriteAlgoFeed(dvm) } - fun unfollowFavoriteDvm(dvm: Address) = launchSigner { account.unfollowFavoriteDvm(dvm) } + fun unfollowFavoriteAlgoFeed(dvm: Address) = launchSigner { account.unfollowFavoriteAlgoFeed(dvm) } - fun refreshFavoriteDvm(dvm: Address) = account.favoriteDvmOrchestrator.refresh(dvm) + fun refreshFavoriteAlgoFeed(dvm: Address) = account.favoriteAlgoFeedsOrchestrator.refresh(dvm) fun followRelayFeed(url: NormalizedRelayUrl) = launchSigner { account.followRelayFeed(url) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt index 0ca21209b..329444e2f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt @@ -49,7 +49,7 @@ import com.vitorpamplona.amethyst.ui.note.LikeReaction import com.vitorpamplona.amethyst.ui.note.ZapReaction import com.vitorpamplona.amethyst.ui.note.elements.BannerImage import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.FavoriteDvmToggle +import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.FavoriteAlgoFeedToggle import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.observeAppDefinition import com.vitorpamplona.amethyst.ui.theme.HalfTopPadding import com.vitorpamplona.amethyst.ui.theme.RowColSpacing5dp @@ -117,7 +117,7 @@ fun RenderContentDVMThumb( modifier = Modifier.weight(1f), ) if (baseNote is AddressableNote) { - FavoriteDvmToggle( + FavoriteAlgoFeedToggle( appDefinitionNote = baseNote, accountViewModel = accountViewModel, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmTopBar.kt index 4ae8cefe5..78e65eed3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmTopBar.kt @@ -102,7 +102,7 @@ fun DvmTopBar( } } addressableNote?.let { target -> - FavoriteDvmToggle( + FavoriteAlgoFeedToggle( appDefinitionNote = target, accountViewModel = accountViewModel, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteDvmToggle.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteAlgoFeedToggle.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteDvmToggle.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteAlgoFeedToggle.kt index 1bed004b7..3838bef64 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteDvmToggle.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteAlgoFeedToggle.kt @@ -52,7 +52,7 @@ import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDi * a 6300 reply that never comes. */ @Composable -fun FavoriteDvmToggle( +fun FavoriteAlgoFeedToggle( appDefinitionNote: AddressableNote, accountViewModel: AccountViewModel, modifier: Modifier = Modifier, @@ -65,7 +65,7 @@ fun FavoriteDvmToggle( if (!supportsContentDiscovery) return - val favorites by accountViewModel.account.favoriteDvmList.flow + val favorites by accountViewModel.account.favoriteAlgoFeedsList.flow .collectAsStateWithLifecycle() val isFavorite = favorites.contains(appDefinitionNote.address) @@ -74,9 +74,9 @@ fun FavoriteDvmToggle( modifier = modifier, onClick = { if (isFavorite) { - accountViewModel.unfollowFavoriteDvm(appDefinitionNote.address) + accountViewModel.unfollowFavoriteAlgoFeed(appDefinitionNote.address) } else { - accountViewModel.followFavoriteDvm( + accountViewModel.followFavoriteAlgoFeed( AddressBookmark( address = appDefinitionNote.address, relayHint = appDefinitionNote.relayHintUrl(), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/favorites/FavoriteDvmListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/favorites/FavoriteAlgoFeedsListScreen.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/favorites/FavoriteDvmListScreen.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/favorites/FavoriteAlgoFeedsListScreen.kt index 0f22ae4ec..8d71292bc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/favorites/FavoriteDvmListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/favorites/FavoriteAlgoFeedsListScreen.kt @@ -70,7 +70,7 @@ import com.vitorpamplona.amethyst.ui.theme.grayText @OptIn(ExperimentalMaterial3Api::class) @Composable -fun FavoriteDvmListScreen( +fun FavoriteAlgoFeedsListScreen( accountViewModel: AccountViewModel, nav: INav, ) { @@ -101,17 +101,17 @@ fun FavoriteDvmListScreen( color = MaterialTheme.colorScheme.grayText, ) - FavoriteDvmList(accountViewModel, nav) + FavoriteAlgoFeedList(accountViewModel, nav) } } } @Composable -private fun FavoriteDvmList( +private fun FavoriteAlgoFeedList( accountViewModel: AccountViewModel, nav: INav, ) { - val favorites by accountViewModel.account.favoriteDvmList.flowNotes + val favorites by accountViewModel.account.favoriteAlgoFeedsList.flowNotes .collectAsStateWithLifecycle() if (favorites.isEmpty()) { @@ -136,12 +136,12 @@ private fun FavoriteDvmList( items( items = favorites, key = { it.address.toValue() }, - ) { dvmNote -> - FavoriteDvmRow( - dvmNote = dvmNote, + ) { feedNote -> + FavoriteAlgoFeedRow( + feedNote = feedNote, accountViewModel = accountViewModel, - onOpen = { nav.nav(Route.ContentDiscovery(dvmNote.idHex)) }, - onRemove = { accountViewModel.unfollowFavoriteDvm(dvmNote.address) }, + onOpen = { nav.nav(Route.ContentDiscovery(feedNote.idHex)) }, + onRemove = { accountViewModel.unfollowFavoriteAlgoFeed(feedNote.address) }, ) } } @@ -149,13 +149,13 @@ private fun FavoriteDvmList( @OptIn(ExperimentalFoundationApi::class) @Composable -private fun FavoriteDvmRow( - dvmNote: AddressableNote, +private fun FavoriteAlgoFeedRow( + feedNote: AddressableNote, accountViewModel: AccountViewModel, onOpen: () -> Unit, onRemove: () -> Unit, ) { - val card = observeAppDefinition(dvmNote, accountViewModel) + val card = observeAppDefinition(feedNote, accountViewModel) Row( modifier = @@ -175,19 +175,19 @@ private fun FavoriteDvmRow( loadedImageModifier = SimpleImage35Modifier, accountViewModel = accountViewModel, onLoadingBackground = { - dvmNote.author?.let { author -> + feedNote.author?.let { author -> BannerImage(author, SimpleImage35Modifier, accountViewModel) } }, onError = { - dvmNote.author?.let { author -> + feedNote.author?.let { author -> BannerImage(author, SimpleImage35Modifier, accountViewModel) } }, ) } } ?: run { - dvmNote.author?.let { author -> + feedNote.author?.let { author -> BannerImage(author, SimpleImage35Modifier, accountViewModel) } } @@ -198,7 +198,7 @@ private fun FavoriteDvmRow( modifier = Modifier.weight(1f), ) { Text( - text = card.name.ifBlank { dvmNote.dTag() }, + text = card.name.ifBlank { feedNote.dTag() }, fontWeight = FontWeight.Bold, maxLines = 1, overflow = TextOverflow.Ellipsis, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/DvmStatusBanner.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/AlgoFeedStatusBanner.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/DvmStatusBanner.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/AlgoFeedStatusBanner.kt index 723eea88a..22d10c444 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/DvmStatusBanner.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/AlgoFeedStatusBanner.kt @@ -42,7 +42,7 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.model.TopFilter -import com.vitorpamplona.amethyst.model.dvms.FavoriteDvmSnapshot +import com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsSnapshot import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteAndMap import com.vitorpamplona.amethyst.ui.components.LoadNote import com.vitorpamplona.amethyst.ui.components.LoadingAnimation @@ -55,7 +55,7 @@ import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent @Composable -fun HomeDvmStatusBanner( +fun HomeAlgoFeedStatusBanner( accountViewModel: AccountViewModel, nav: INav, modifier: Modifier = Modifier, @@ -64,31 +64,31 @@ fun HomeDvmStatusBanner( .collectAsStateWithLifecycle() when (val filter = topFilter) { - is TopFilter.FavoriteDvm -> SingleDvmBanner(filter, accountViewModel, nav, modifier) - is TopFilter.AllFavoriteDvms -> AllFavoriteDvmsBanner(accountViewModel, modifier) + is TopFilter.FavoriteAlgoFeed -> SingleAlgoFeedBanner(filter, accountViewModel, nav, modifier) + is TopFilter.AllFavoriteAlgoFeeds -> AllFavoriteAlgoFeedsBanner(accountViewModel, modifier) else -> Unit } } @Composable -private fun SingleDvmBanner( - favDvm: TopFilter.FavoriteDvm, +private fun SingleAlgoFeedBanner( + favFeed: TopFilter.FavoriteAlgoFeed, accountViewModel: AccountViewModel, nav: INav, modifier: Modifier = Modifier, ) { - val snapshot by accountViewModel.account.favoriteDvmOrchestrator - .observe(favDvm.address) + val snapshot by accountViewModel.account.favoriteAlgoFeedsOrchestrator + .observe(favFeed.address) .collectAsStateWithLifecycle() // Hide the banner when the feed is already populated. if (snapshot.ids.isNotEmpty() || snapshot.addresses.isNotEmpty()) return - val dvmAddressValue = favDvm.address.toValue() + val feedAddressValue = favFeed.address.toValue() - LoadNote(baseNoteHex = dvmAddressValue, accountViewModel = accountViewModel) { dvmNote -> + LoadNote(baseNoteHex = feedAddressValue, accountViewModel = accountViewModel) { feedNote -> val resolvedName by - observeNoteAndMap(dvmNote ?: return@LoadNote, accountViewModel) { note -> + observeNoteAndMap(feedNote ?: return@LoadNote, accountViewModel) { note -> (note.event as? AppDefinitionEvent) ?.appMetaData() ?.name @@ -107,7 +107,7 @@ private fun SingleDvmBanner( showSpinner = false, ) Spacer(modifier = StdVertSpacer) - RetryButton { accountViewModel.refreshFavoriteDvm(favDvm.address) } + RetryButton { accountViewModel.refreshFavoriteAlgoFeed(favFeed.address) } } status?.code == "payment-required" -> { @@ -144,7 +144,7 @@ private fun SingleDvmBanner( showSpinner = false, ) Spacer(modifier = StdVertSpacer) - RetryButton { accountViewModel.refreshFavoriteDvm(favDvm.address) } + RetryButton { accountViewModel.refreshFavoriteAlgoFeed(favFeed.address) } } status?.code == "processing" -> { @@ -169,11 +169,11 @@ private fun SingleDvmBanner( } @Composable -private fun AllFavoriteDvmsBanner( +private fun AllFavoriteAlgoFeedsBanner( accountViewModel: AccountViewModel, modifier: Modifier = Modifier, ) { - val addresses by accountViewModel.account.favoriteDvmList.flow + val addresses by accountViewModel.account.favoriteAlgoFeedsList.flow .collectAsStateWithLifecycle() if (addresses.isEmpty()) return @@ -181,9 +181,9 @@ private fun AllFavoriteDvmsBanner( // Observe each DVM's snapshot so we can decide whether to hide the banner // based on the aggregate state. Hide it as soon as any DVM has produced a // feed; only error out when every one of them has errored. - val snapshots: List = + val snapshots: List = addresses.map { address -> - val snap by accountViewModel.account.favoriteDvmOrchestrator + val snap by accountViewModel.account.favoriteAlgoFeedsOrchestrator .observe(address) .collectAsStateWithLifecycle() snap @@ -202,7 +202,7 @@ private fun AllFavoriteDvmsBanner( ) Spacer(modifier = StdVertSpacer) RetryButton { - addresses.forEach { accountViewModel.refreshFavoriteDvm(it) } + addresses.forEach { accountViewModel.refreshFavoriteAlgoFeed(it) } } } else { BannerMessageRow( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt index d3f676146..fb2ee8914 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt @@ -240,7 +240,7 @@ private fun HomePages( ) } - HomeDvmStatusBanner( + HomeAlgoFeedStatusBanner( accountViewModel = accountViewModel, nav = nav, modifier = Modifier.align(Alignment.TopCenter), @@ -300,7 +300,7 @@ fun HomeFeeds( ) { val activeFilter by accountViewModel.account.settings.defaultHomeFollowList .collectAsStateWithLifecycle() - val favoriteDvmAddresses by accountViewModel.account.favoriteDvmList.flow + val favoriteAlgoFeedAddresses by accountViewModel.account.favoriteAlgoFeedsList.flow .collectAsStateWithLifecycle() val onRefresh: () -> Unit = { @@ -308,8 +308,8 @@ fun HomeFeeds( // Swiping down on Home should also re-issue the kind-5300 request(s) so the // DVM(s) produce fresh feeds, not just re-render whatever's cached. when (val filter = activeFilter) { - is TopFilter.FavoriteDvm -> accountViewModel.refreshFavoriteDvm(filter.address) - is TopFilter.AllFavoriteDvms -> favoriteDvmAddresses.forEach { accountViewModel.refreshFavoriteDvm(it) } + is TopFilter.FavoriteAlgoFeed -> accountViewModel.refreshFavoriteAlgoFeed(filter.address) + is TopFilter.AllFavoriteAlgoFeeds -> favoriteAlgoFeedAddresses.forEach { accountViewModel.refreshFavoriteAlgoFeed(it) } else -> Unit } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt index 29abc2ae6..09488ead9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.model.topNavFeeds.chess.ChessTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet @@ -43,7 +43,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip01Core.f import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip64Chess.filterHomePostsByChess import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip72Communities.filterHomePostsByAllCommunities import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip72Communities.filterHomePostsByCommunity -import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip90Dvms.filterHomePostsByDvmIds +import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip90AlgoFeeds.filterHomePostsByAlgoFeedIds 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 @@ -76,7 +76,7 @@ class HomeOutboxEventsEoseManager( is MutedAuthorsTopNavPerRelayFilterSet -> filterHomePostsByAuthors(feedSettings, since, newThreadSince, repliesSince) is RelayTopNavPerRelayFilterSet -> filterHomePostsByRelay(feedSettings, since, newThreadSince, repliesSince) is SingleCommunityTopNavPerRelayFilterSet -> filterHomePostsByCommunity(feedSettings, since, newThreadSince) - is FavoriteDvmTopNavPerRelayFilterSet -> filterHomePostsByDvmIds(feedSettings, since, newThreadSince) + is FavoriteAlgoFeedTopNavPerRelayFilterSet -> filterHomePostsByAlgoFeedIds(feedSettings, since, newThreadSince) else -> emptyList() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90Dvms/FilterHomePostsByDvmIds.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIds.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90Dvms/FilterHomePostsByDvmIds.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIds.kt index c042199a6..029546417 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90Dvms/FilterHomePostsByDvmIds.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIds.kt @@ -18,10 +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.home.datasource.nip90Dvms +package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip90AlgoFeeds -import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmTopNavPerRelayFilter -import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilter +import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilterSet import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter @@ -45,8 +45,8 @@ import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent * never publishes responses on the user's outbox, so listening anywhere else * would silently miss them. */ -fun filterHomePostsByDvmIds( - set: FavoriteDvmTopNavPerRelayFilterSet, +fun filterHomePostsByAlgoFeedIds( + set: FavoriteAlgoFeedTopNavPerRelayFilterSet, @Suppress("UNUSED_PARAMETER") since: SincePerRelayMap?, @Suppress("UNUSED_PARAMETER") defaultSince: Long?, ): List { @@ -68,7 +68,7 @@ fun filterHomePostsByDvmIds( private fun contentFetchFilters( relay: NormalizedRelayUrl, - filter: FavoriteDvmTopNavPerRelayFilter, + filter: FavoriteAlgoFeedTopNavPerRelayFilter, ): List { val out = mutableListOf() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AllSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AllSettingsScreen.kt index 69207a03b..6175115ac 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AllSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AllSettingsScreen.kt @@ -127,7 +127,7 @@ fun AllSettingsScreen( title = R.string.favorite_dvms_title, icon = Icons.Outlined.AutoAwesome, tint = tint, - onClick = { nav.nav(Route.EditFavoriteDvms) }, + onClick = { nav.nav(Route.EditFavoriteAlgoFeeds) }, ) HorizontalDivider() SettingsNavigationRow( diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavFilterTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilterTest.kt similarity index 87% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavFilterTest.kt rename to amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilterTest.kt index c55e3927e..0e8594af8 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteDvm/FavoriteDvmTopNavFilterTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilterTest.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.model.topNavFeeds.favoriteDvm +package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent @@ -27,7 +27,7 @@ import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test -class FavoriteDvmTopNavFilterTest { +class FavoriteAlgoFeedTopNavFilterTest { private fun textNote(id: String) = TextNoteEvent(id = id, pubKey = "a".repeat(64), createdAt = 1, tags = emptyArray(), content = "", sig = "x".repeat(128)) private fun longFormNote( @@ -47,8 +47,8 @@ class FavoriteDvmTopNavFilterTest { @Test fun matchesNoteWhoseIdIsInAcceptedSet() { val filter = - FavoriteDvmTopNavFilter( - dvmAddress = dvmAddress, + FavoriteAlgoFeedTopNavFilter( + feedAddress = dvmAddress, acceptedIds = setOf("1".repeat(64)), acceptedAddresses = emptySet(), contentRelays = emptySet(), @@ -62,8 +62,8 @@ class FavoriteDvmTopNavFilterTest { @Test fun rejectsNoteNotInAcceptedSet() { val filter = - FavoriteDvmTopNavFilter( - dvmAddress = dvmAddress, + FavoriteAlgoFeedTopNavFilter( + feedAddress = dvmAddress, acceptedIds = setOf("1".repeat(64)), acceptedAddresses = emptySet(), contentRelays = emptySet(), @@ -81,8 +81,8 @@ class FavoriteDvmTopNavFilterTest { val articleAddress = "30023:$articleAuthor:$articleDTag" val filter = - FavoriteDvmTopNavFilter( - dvmAddress = dvmAddress, + FavoriteAlgoFeedTopNavFilter( + feedAddress = dvmAddress, acceptedIds = emptySet(), acceptedAddresses = setOf(articleAddress), contentRelays = emptySet(), @@ -96,8 +96,8 @@ class FavoriteDvmTopNavFilterTest { @Test fun nullRequestIdCollapsesToEmptyRequestIdsInFilterSet() { val filter = - FavoriteDvmTopNavFilter( - dvmAddress = dvmAddress, + FavoriteAlgoFeedTopNavFilter( + feedAddress = dvmAddress, acceptedIds = emptySet(), acceptedAddresses = emptySet(), contentRelays = emptySet(), @@ -106,7 +106,7 @@ class FavoriteDvmTopNavFilterTest { ) // passing a LocalCache is only needed because the method demands it; - // FavoriteDvmTopNavFilter.startValue doesn't actually consult it. + // FavoriteAlgoFeedTopNavFilter.startValue doesn't actually consult it. val set = filter.startValue(com.vitorpamplona.amethyst.model.LocalCache) assertTrue(set.requestIds.isEmpty()) } @@ -114,8 +114,8 @@ class FavoriteDvmTopNavFilterTest { @Test fun nonNullRequestIdProducesSingletonInFilterSet() { val filter = - FavoriteDvmTopNavFilter( - dvmAddress = dvmAddress, + FavoriteAlgoFeedTopNavFilter( + feedAddress = dvmAddress, acceptedIds = emptySet(), acceptedAddresses = emptySet(), contentRelays = emptySet(), diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90Dvms/FilterHomePostsByDvmIdsTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIdsTest.kt similarity index 78% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90Dvms/FilterHomePostsByDvmIdsTest.kt rename to amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIdsTest.kt index 62086f8b3..5ae5d27a1 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90Dvms/FilterHomePostsByDvmIdsTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIdsTest.kt @@ -18,10 +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.home.datasource.nip90Dvms +package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip90AlgoFeeds -import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmTopNavPerRelayFilter -import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmTopNavPerRelayFilterSet +import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilter +import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilterSet import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent @@ -30,34 +30,34 @@ import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue import org.junit.Test -class FilterHomePostsByDvmIdsTest { +class FilterHomePostsByAlgoFeedIdsTest { private val userRelay = RelayUrlNormalizer.normalizeOrNull("wss://user.example/")!! private val dvmRelay = RelayUrlNormalizer.normalizeOrNull("wss://dvm.example/")!! @Test fun emptyFilterSetProducesNoRequests() { val set = - FavoriteDvmTopNavPerRelayFilterSet( + FavoriteAlgoFeedTopNavPerRelayFilterSet( contentFetches = emptyMap(), listenRelays = emptySet(), requestIds = emptySet(), ) - assertTrue(filterHomePostsByDvmIds(set, since = null, defaultSince = null).isEmpty()) + assertTrue(filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null).isEmpty()) } @Test fun contentFetchIssuedOnUserRelayWithIdsFilter() { val ids = setOf("a".repeat(64), "b".repeat(64)) val set = - FavoriteDvmTopNavPerRelayFilterSet( + FavoriteAlgoFeedTopNavPerRelayFilterSet( contentFetches = - mapOf(userRelay to FavoriteDvmTopNavPerRelayFilter(ids = ids, addresses = emptySet())), + mapOf(userRelay to FavoriteAlgoFeedTopNavPerRelayFilter(ids = ids, addresses = emptySet())), listenRelays = emptySet(), requestIds = emptySet(), ) - val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null) + val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null) assertEquals(1, filters.size) val single = filters.single() @@ -71,13 +71,13 @@ class FilterHomePostsByDvmIdsTest { fun listenFilterIssuedOnDvmRelayWithKinds6300And7000() { val requestId = "9".repeat(64) val set = - FavoriteDvmTopNavPerRelayFilterSet( + FavoriteAlgoFeedTopNavPerRelayFilterSet( contentFetches = emptyMap(), listenRelays = setOf(dvmRelay), requestIds = setOf(requestId), ) - val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null) + val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null) assertEquals(1, filters.size) val listen = filters.single() @@ -96,13 +96,13 @@ class FilterHomePostsByDvmIdsTest { val req1 = "1".repeat(64) val req2 = "2".repeat(64) val set = - FavoriteDvmTopNavPerRelayFilterSet( + FavoriteAlgoFeedTopNavPerRelayFilterSet( contentFetches = emptyMap(), listenRelays = setOf(dvmRelay), requestIds = setOf(req1, req2), ) - val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null) + val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null) assertEquals(1, filters.size) val eTag = @@ -120,14 +120,14 @@ class FilterHomePostsByDvmIdsTest { val ids = setOf("a".repeat(64)) val requestId = "9".repeat(64) val set = - FavoriteDvmTopNavPerRelayFilterSet( + FavoriteAlgoFeedTopNavPerRelayFilterSet( contentFetches = - mapOf(userRelay to FavoriteDvmTopNavPerRelayFilter(ids = ids, addresses = emptySet())), + mapOf(userRelay to FavoriteAlgoFeedTopNavPerRelayFilter(ids = ids, addresses = emptySet())), listenRelays = setOf(dvmRelay), requestIds = setOf(requestId), ) - val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null) + val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null) assertEquals(2, filters.size) assertTrue(filters.any { it.relay == userRelay && it.filter.ids != null })