refactor: rename FavoriteDvm* -> FavoriteAlgoFeed* throughout amethyst
The wire-level class was renamed to FavoriteAlgoFeedsListEvent in a
prior commit. Finish the rename through the rest of the feature so
the internal vocabulary (packages, classes, properties, routes, DSL
helpers, TopFilter variants, composables) matches what users see.
Packages:
- model.nip51Lists.favoriteDvmLists -> favoriteAlgoFeedsLists
- model.dvms -> algoFeeds
- model.topNavFeeds.favoriteDvm -> favoriteAlgoFeeds
- home.datasource.nip90Dvms -> nip90AlgoFeeds
Classes/composables renamed (selected):
- FavoriteDvmListState/DecryptionCache -> FavoriteAlgoFeedsListState/DecryptionCache
- FavoriteDvmOrchestrator / FavoriteDvmSnapshot -> FavoriteAlgoFeedsOrchestrator / FavoriteAlgoFeedsSnapshot
- FavoriteDvmTopNavFilter{,PerRelayFilter{,Set}}, FavoriteDvmFeedFlow ->
FavoriteAlgoFeedTopNavFilter{,PerRelayFilter{,Set}}, FavoriteAlgoFeedFlow
- AllFavoriteDvmsTopNavFilter / AllFavoriteDvmsFeedFlow / AllFavoriteDvmsBanner ->
AllFavoriteAlgoFeedsTopNavFilter / AllFavoriteAlgoFeedsFlow / AllFavoriteAlgoFeedsBanner
- FavoriteDvmName -> FavoriteAlgoFeedName
- FavoriteDvmToggle -> FavoriteAlgoFeedToggle
- FavoriteDvmListScreen -> FavoriteAlgoFeedsListScreen
- HomeDvmStatusBanner / SingleDvmBanner / DvmStatusBanner ->
HomeAlgoFeedStatusBanner / SingleAlgoFeedBanner / AlgoFeedStatusBanner
- filterHomePostsByDvmIds -> filterHomePostsByAlgoFeedIds
- TopFilter.FavoriteDvm / TopFilter.AllFavoriteDvms ->
TopFilter.FavoriteAlgoFeed / TopFilter.AllFavoriteAlgoFeeds
- Route.EditFavoriteDvms -> Route.EditFavoriteAlgoFeeds
Account / AccountSettings / AccountViewModel properties & mutators
renamed consistently: favoriteDvmList -> favoriteAlgoFeedsList,
backupFavoriteDvmList -> backupFavoriteAlgoFeedsList, follow/unfollow/
isFavoriteDvm -> follow/unfollow/isFavoriteAlgoFeed, refreshFavoriteDvm
-> refreshFavoriteAlgoFeed, dvmAddress kwargs -> feedAddress,
dvmNote locals -> feedNote, etc.
Persisted TopFilter.FavoriteAlgoFeed/AllFavoriteAlgoFeeds `code` strings
changed (old "FavoriteDvm/…" / " All Favourite DVMs " values don't
round-trip anymore) — kotlinx-serialization polymorphism keys the
sealed class by class name, so cold-start of pre-existing installs
will fall back to AllFollows for this filter. Acceptable since this
is a new feature only on this branch.
Kept unchanged: ui/screen/loggedIn/dvms/ folder (hosts generic
DvmContentDiscoveryScreen / DvmTopBar / DvmPaymentActions), quartz
nip90Dvms package (NIP-90 wire-protocol naming). XML string resource
keys (favorite_dvms_title, dvm_home_* etc) kept stable; only their
values were updated previously.
Build + tests green on both modules.
This commit is contained in:
@@ -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.model.nip56Reports.ReportAction
|
||||||
import com.vitorpamplona.amethyst.commons.richtext.RichTextParser
|
import com.vitorpamplona.amethyst.commons.richtext.RichTextParser
|
||||||
import com.vitorpamplona.amethyst.logTime
|
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.PrivateStorageRelayListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
|
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.localRelays.ForwardKind0ToLocalRelayState
|
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.blockedRelays.BlockedRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.favoriteDvmLists.FavoriteDvmListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.favoriteAlgoFeedsLists.FavoriteAlgoFeedsListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.favoriteDvmLists.FavoriteDvmListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.favoriteAlgoFeedsLists.FavoriteAlgoFeedsListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListDecryptionCache
|
||||||
@@ -327,9 +327,9 @@ class Account(
|
|||||||
val hashtagListDecryptionCache = HashtagListDecryptionCache(signer)
|
val hashtagListDecryptionCache = HashtagListDecryptionCache(signer)
|
||||||
val hashtagList = HashtagListState(signer, cache, hashtagListDecryptionCache, scope, settings)
|
val hashtagList = HashtagListState(signer, cache, hashtagListDecryptionCache, scope, settings)
|
||||||
|
|
||||||
val favoriteDvmListDecryptionCache = FavoriteDvmListDecryptionCache(signer)
|
val favoriteAlgoFeedsListDecryptionCache = FavoriteAlgoFeedsListDecryptionCache(signer)
|
||||||
val favoriteDvmList = FavoriteDvmListState(signer, cache, favoriteDvmListDecryptionCache, scope, settings)
|
val favoriteAlgoFeedsList = FavoriteAlgoFeedsListState(signer, cache, favoriteAlgoFeedsListDecryptionCache, scope, settings)
|
||||||
val favoriteDvmOrchestrator = FavoriteDvmOrchestrator(this, scope)
|
val favoriteAlgoFeedsOrchestrator = FavoriteAlgoFeedsOrchestrator(this, scope)
|
||||||
|
|
||||||
val geohashListDecryptionCache = GeohashListDecryptionCache(signer)
|
val geohashListDecryptionCache = GeohashListDecryptionCache(signer)
|
||||||
val geohashList = GeohashListState(signer, cache, geohashListDecryptionCache, scope, settings)
|
val geohashList = GeohashListState(signer, cache, geohashListDecryptionCache, scope, settings)
|
||||||
@@ -426,8 +426,8 @@ class Account(
|
|||||||
caches = feedDecryptionCaches,
|
caches = feedDecryptionCaches,
|
||||||
signer = signer,
|
signer = signer,
|
||||||
scope = scope,
|
scope = scope,
|
||||||
favoriteDvmOrchestrator = favoriteDvmOrchestrator,
|
favoriteAlgoFeedsOrchestrator = favoriteAlgoFeedsOrchestrator,
|
||||||
favoriteDvmAddresses = favoriteDvmList.flow,
|
favoriteAlgoFeedAddresses = favoriteAlgoFeedsList.flow,
|
||||||
).flow
|
).flow
|
||||||
|
|
||||||
// App-ready Feeds
|
// App-ready Feeds
|
||||||
@@ -1023,11 +1023,11 @@ class Account(
|
|||||||
|
|
||||||
suspend fun unfollowHashtag(tag: String) = sendMyPublicAndPrivateOutbox(hashtagList.unfollow(tag))
|
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))
|
suspend fun followGeohash(geohash: String) = sendMyPublicAndPrivateOutbox(geohashList.follow(geohash))
|
||||||
|
|
||||||
|
|||||||
@@ -157,11 +157,11 @@ sealed class TopFilter(
|
|||||||
) : TopFilter("Relay/$url")
|
) : TopFilter("Relay/$url")
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class FavoriteDvm(
|
class FavoriteAlgoFeed(
|
||||||
val address: Address,
|
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
|
@Stable
|
||||||
@@ -203,7 +203,7 @@ class AccountSettings(
|
|||||||
var backupChannelList: ChannelListEvent? = null,
|
var backupChannelList: ChannelListEvent? = null,
|
||||||
var backupCommunityList: CommunityListEvent? = null,
|
var backupCommunityList: CommunityListEvent? = null,
|
||||||
var backupHashtagList: HashtagListEvent? = null,
|
var backupHashtagList: HashtagListEvent? = null,
|
||||||
var backupFavoriteDvmList: FavoriteAlgoFeedsListEvent? = null,
|
var backupFavoriteAlgoFeedsList: FavoriteAlgoFeedsListEvent? = null,
|
||||||
var backupGeohashList: GeohashListEvent? = null,
|
var backupGeohashList: GeohashListEvent? = null,
|
||||||
var backupEphemeralChatList: EphemeralChatListEvent? = null,
|
var backupEphemeralChatList: EphemeralChatListEvent? = null,
|
||||||
var backupTrustProviderList: TrustProviderListEvent? = 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
|
if (newFavoriteDvmList == null || newFavoriteDvmList.tags.isEmpty()) return
|
||||||
|
|
||||||
// Events might be different objects, we have to compare their ids.
|
// Events might be different objects, we have to compare their ids.
|
||||||
if (backupFavoriteDvmList?.id != newFavoriteDvmList.id) {
|
if (backupFavoriteAlgoFeedsList?.id != newFavoriteDvmList.id) {
|
||||||
backupFavoriteDvmList = newFavoriteDvmList
|
backupFavoriteAlgoFeedsList = newFavoriteDvmList
|
||||||
saveAccountSettings()
|
saveAccountSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-24
@@ -18,7 +18,7 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.amethyst.model.Account
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Address
|
import com.vitorpamplona.quartz.nip01Core.core.Address
|
||||||
@@ -45,7 +45,7 @@ import kotlinx.coroutines.sync.withLock
|
|||||||
private const val RESPONSE_TIMEOUT_MS = 20_000L
|
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.
|
* - [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
|
* - [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, …).
|
* - [latestStatus] is the latest kind-7000 status event (processing, payment-required, error, …).
|
||||||
* - [errorMessage] captures any client-side failure while publishing the request.
|
* - [errorMessage] captures any client-side failure while publishing the request.
|
||||||
*/
|
*/
|
||||||
data class FavoriteDvmSnapshot(
|
data class FavoriteAlgoFeedsSnapshot(
|
||||||
val requestId: HexKey? = null,
|
val requestId: HexKey? = null,
|
||||||
val responseRelays: Set<NormalizedRelayUrl> = emptySet(),
|
val responseRelays: Set<NormalizedRelayUrl> = emptySet(),
|
||||||
val ids: Set<HexKey> = emptySet(),
|
val ids: Set<HexKey> = 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.
|
* pins to the top-nav.
|
||||||
*
|
*
|
||||||
* The orchestrator is lazy: it starts a request/response cycle the first time any
|
* 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
|
* This class does not own the relay subscriptions that fetch DVM responses and
|
||||||
* matching notes. Those are issued by `HomeOutboxEventsEoseManager` while the
|
* 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`.
|
* what the relays deliver into `LocalCache`.
|
||||||
*/
|
*/
|
||||||
class FavoriteDvmOrchestrator(
|
class FavoriteAlgoFeedsOrchestrator(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
val scope: CoroutineScope,
|
val scope: CoroutineScope,
|
||||||
) {
|
) {
|
||||||
private val flows = mutableMapOf<Address, MutableStateFlow<FavoriteDvmSnapshot>>()
|
private val flows = mutableMapOf<Address, MutableStateFlow<FavoriteAlgoFeedsSnapshot>>()
|
||||||
private val jobs = mutableMapOf<Address, Job>()
|
private val jobs = mutableMapOf<Address, Job>()
|
||||||
private val mutex = Mutex()
|
private val mutex = Mutex()
|
||||||
|
|
||||||
fun observe(dvmAddress: Address): StateFlow<FavoriteDvmSnapshot> {
|
fun observe(feedAddress: Address): StateFlow<FavoriteAlgoFeedsSnapshot> {
|
||||||
flows[dvmAddress]?.let { return it.asStateFlow() }
|
flows[feedAddress]?.let { return it.asStateFlow() }
|
||||||
|
|
||||||
val seed = MutableStateFlow(FavoriteDvmSnapshot())
|
val seed = MutableStateFlow(FavoriteAlgoFeedsSnapshot())
|
||||||
flows[dvmAddress] = seed
|
flows[feedAddress] = seed
|
||||||
scope.launch { startFor(dvmAddress, seed) }
|
scope.launch { startFor(feedAddress, seed) }
|
||||||
return seed.asStateFlow()
|
return seed.asStateFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refresh(dvmAddress: Address) {
|
fun refresh(feedAddress: Address) {
|
||||||
val seed = flows[dvmAddress] ?: return
|
val seed = flows[feedAddress] ?: return
|
||||||
scope.launch {
|
scope.launch {
|
||||||
mutex.withLock {
|
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 {
|
scope.launch {
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
jobs.remove(dvmAddress)?.cancel()
|
jobs.remove(feedAddress)?.cancel()
|
||||||
flows.remove(dvmAddress)
|
flows.remove(feedAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun startFor(
|
private suspend fun startFor(
|
||||||
dvmAddress: Address,
|
feedAddress: Address,
|
||||||
seed: MutableStateFlow<FavoriteDvmSnapshot>,
|
seed: MutableStateFlow<FavoriteAlgoFeedsSnapshot>,
|
||||||
) {
|
) {
|
||||||
val user = account.cache.checkGetOrCreateUser(dvmAddress.pubKeyHex) ?: return
|
val user = account.cache.checkGetOrCreateUser(feedAddress.pubKeyHex) ?: return
|
||||||
val job =
|
val job =
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
@@ -188,12 +188,12 @@ class FavoriteDvmOrchestrator(
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (e is CancellationException) throw e
|
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") }
|
seed.update { it.copy(errorMessage = e.message ?: "Unknown error") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.withLock { jobs[dvmAddress] = job }
|
mutex.withLock { jobs[feedAddress] = job }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun splitInnerTags(innerTags: List<HexKey>): Pair<Set<HexKey>, Set<String>> {
|
private fun splitInnerTags(innerTags: List<HexKey>): Pair<Set<HexKey>, Set<String>> {
|
||||||
+4
-4
@@ -18,19 +18,19 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache
|
import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache
|
||||||
import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent
|
import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.favoriteAlgoFeedsSet
|
import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.favoriteAlgoFeedsSet
|
||||||
|
|
||||||
class FavoriteDvmListDecryptionCache(
|
class FavoriteAlgoFeedsListDecryptionCache(
|
||||||
val signer: NostrSigner,
|
val signer: NostrSigner,
|
||||||
) {
|
) {
|
||||||
val cachedPrivateLists = PrivateTagArrayEventCache<FavoriteAlgoFeedsListEvent>(signer)
|
val cachedPrivateLists = PrivateTagArrayEventCache<FavoriteAlgoFeedsListEvent>(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()
|
||||||
}
|
}
|
||||||
+18
-18
@@ -18,7 +18,7 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.AccountSettings
|
||||||
import com.vitorpamplona.amethyst.model.AddressableNote
|
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||||
@@ -43,34 +43,34 @@ import kotlinx.coroutines.flow.stateIn
|
|||||||
import kotlinx.coroutines.flow.transformLatest
|
import kotlinx.coroutines.flow.transformLatest
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class FavoriteDvmListState(
|
class FavoriteAlgoFeedsListState(
|
||||||
val signer: NostrSigner,
|
val signer: NostrSigner,
|
||||||
val cache: LocalCache,
|
val cache: LocalCache,
|
||||||
val decryptionCache: FavoriteDvmListDecryptionCache,
|
val decryptionCache: FavoriteAlgoFeedsListDecryptionCache,
|
||||||
val scope: CoroutineScope,
|
val scope: CoroutineScope,
|
||||||
val settings: AccountSettings,
|
val settings: AccountSettings,
|
||||||
) {
|
) {
|
||||||
// Creates a long-term reference for this note so that the GC doesn't collect the note itself
|
// 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<NoteState> = favoriteDvmListNote.flow().metadata.stateFlow
|
fun getFavoriteAlgoFeedsListFlow(): StateFlow<NoteState> = favoriteAlgoFeedsListNote.flow().metadata.stateFlow
|
||||||
|
|
||||||
fun getFavoriteDvmList(): FavoriteAlgoFeedsListEvent? = favoriteDvmListNote.event as? FavoriteAlgoFeedsListEvent
|
fun getFavoriteAlgoFeedsList(): FavoriteAlgoFeedsListEvent? = favoriteAlgoFeedsListNote.event as? FavoriteAlgoFeedsListEvent
|
||||||
|
|
||||||
suspend fun favoriteDvmListWithBackup(note: Note): Set<Address> {
|
suspend fun favoriteAlgoFeedsListWithBackup(note: Note): Set<Address> {
|
||||||
val event = note.event as? FavoriteAlgoFeedsListEvent ?: settings.backupFavoriteDvmList
|
val event = note.event as? FavoriteAlgoFeedsListEvent ?: settings.backupFavoriteAlgoFeedsList
|
||||||
return event?.let { decryptionCache.favoriteDvms(it) } ?: emptySet()
|
return event?.let { decryptionCache.favoriteAlgoFeeds(it) } ?: emptySet()
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
val flow: StateFlow<Set<Address>> =
|
val flow: StateFlow<Set<Address>> =
|
||||||
getFavoriteDvmListFlow()
|
getFavoriteAlgoFeedsListFlow()
|
||||||
.transformLatest { noteState ->
|
.transformLatest { noteState ->
|
||||||
emit(favoriteDvmListWithBackup(noteState.note))
|
emit(favoriteAlgoFeedsListWithBackup(noteState.note))
|
||||||
}.onStart {
|
}.onStart {
|
||||||
emit(favoriteDvmListWithBackup(favoriteDvmListNote))
|
emit(favoriteAlgoFeedsListWithBackup(favoriteAlgoFeedsListNote))
|
||||||
}.flowOn(Dispatchers.IO)
|
}.flowOn(Dispatchers.IO)
|
||||||
.stateIn(
|
.stateIn(
|
||||||
scope,
|
scope,
|
||||||
@@ -93,7 +93,7 @@ class FavoriteDvmListState(
|
|||||||
)
|
)
|
||||||
|
|
||||||
suspend fun follow(dvm: AddressBookmark): FavoriteAlgoFeedsListEvent {
|
suspend fun follow(dvm: AddressBookmark): FavoriteAlgoFeedsListEvent {
|
||||||
val list = getFavoriteDvmList()
|
val list = getFavoriteAlgoFeedsList()
|
||||||
return if (list == null) {
|
return if (list == null) {
|
||||||
FavoriteAlgoFeedsListEvent.create(dvm, false, signer)
|
FavoriteAlgoFeedsListEvent.create(dvm, false, signer)
|
||||||
} else {
|
} else {
|
||||||
@@ -102,12 +102,12 @@ class FavoriteDvmListState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun unfollow(dvm: Address): FavoriteAlgoFeedsListEvent? {
|
suspend fun unfollow(dvm: Address): FavoriteAlgoFeedsListEvent? {
|
||||||
val list = getFavoriteDvmList() ?: return null
|
val list = getFavoriteAlgoFeedsList() ?: return null
|
||||||
return FavoriteAlgoFeedsListEvent.remove(list, dvm, signer)
|
return FavoriteAlgoFeedsListEvent.remove(list, dvm, signer)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
settings.backupFavoriteDvmList?.let { event ->
|
settings.backupFavoriteAlgoFeedsList?.let { event ->
|
||||||
Log.d("AccountRegisterObservers") { "Loading saved Favorite DVM list ${event.toJson()}" }
|
Log.d("AccountRegisterObservers") { "Loading saved Favorite DVM list ${event.toJson()}" }
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
@@ -117,10 +117,10 @@ class FavoriteDvmListState(
|
|||||||
|
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
Log.d("AccountRegisterObservers", "Favorite DVM List Collector Start")
|
Log.d("AccountRegisterObservers", "Favorite DVM List Collector Start")
|
||||||
getFavoriteDvmListFlow().collect {
|
getFavoriteAlgoFeedsListFlow().collect {
|
||||||
Log.d("AccountRegisterObservers") { "Favorite DVM List for ${signer.pubKey}" }
|
Log.d("AccountRegisterObservers") { "Favorite DVM List for ${signer.pubKey}" }
|
||||||
(it.note.event as? FavoriteAlgoFeedsListEvent)?.let {
|
(it.note.event as? FavoriteAlgoFeedsListEvent)?.let {
|
||||||
settings.updateFavoriteDvmListTo(it)
|
settings.updateFavoriteAlgoFeedsListTo(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-13
@@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.model.topNavFeeds
|
|||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.TopFilter
|
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.nip02FollowLists.Kind3FollowListState
|
||||||
import com.vitorpamplona.amethyst.model.serverList.MergedFollowListsState
|
import com.vitorpamplona.amethyst.model.serverList.MergedFollowListsState
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.allFollows.AllFollowsFeedFlow
|
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.AroundMeFeedFlow
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.GeohashFeedFlow
|
import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.GeohashFeedFlow
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.chess.ChessFeedFlow
|
import com.vitorpamplona.amethyst.model.topNavFeeds.chess.ChessFeedFlow
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.AllFavoriteDvmsFeedFlow
|
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.AllFavoriteAlgoFeedsFlow
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmFeedFlow
|
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedFlow
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalFeedFlow
|
import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalFeedFlow
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagFeedFlow
|
import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagFeedFlow
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.NoteFeedFlow
|
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.NoteFeedFlow
|
||||||
@@ -66,8 +66,8 @@ class FeedTopNavFilterState(
|
|||||||
val caches: FeedDecryptionCaches,
|
val caches: FeedDecryptionCaches,
|
||||||
val signer: NostrSigner,
|
val signer: NostrSigner,
|
||||||
val scope: CoroutineScope,
|
val scope: CoroutineScope,
|
||||||
val favoriteDvmOrchestrator: FavoriteDvmOrchestrator,
|
val favoriteAlgoFeedsOrchestrator: FavoriteAlgoFeedsOrchestrator,
|
||||||
val favoriteDvmAddresses: StateFlow<Set<Address>>,
|
val favoriteAlgoFeedAddresses: StateFlow<Set<Address>>,
|
||||||
) {
|
) {
|
||||||
fun loadFlowsFor(listName: TopFilter): IFeedFlowsType =
|
fun loadFlowsFor(listName: TopFilter): IFeedFlowsType =
|
||||||
when (listName) {
|
when (listName) {
|
||||||
@@ -149,19 +149,19 @@ class FeedTopNavFilterState(
|
|||||||
RelayFeedFlow(listName.url.normalizeRelayUrl())
|
RelayFeedFlow(listName.url.normalizeRelayUrl())
|
||||||
}
|
}
|
||||||
|
|
||||||
is TopFilter.FavoriteDvm -> {
|
is TopFilter.FavoriteAlgoFeed -> {
|
||||||
FavoriteDvmFeedFlow(
|
FavoriteAlgoFeedFlow(
|
||||||
dvmAddress = listName.address,
|
feedAddress = listName.address,
|
||||||
orchestrator = favoriteDvmOrchestrator,
|
orchestrator = favoriteAlgoFeedsOrchestrator,
|
||||||
outboxRelays = followsRelays,
|
outboxRelays = followsRelays,
|
||||||
proxyRelays = proxyRelays,
|
proxyRelays = proxyRelays,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
TopFilter.AllFavoriteDvms -> {
|
TopFilter.AllFavoriteAlgoFeeds -> {
|
||||||
AllFavoriteDvmsFeedFlow(
|
AllFavoriteAlgoFeedsFlow(
|
||||||
favoriteDvmAddresses = favoriteDvmAddresses,
|
favoriteAlgoFeedAddresses = favoriteAlgoFeedAddresses,
|
||||||
orchestrator = favoriteDvmOrchestrator,
|
orchestrator = favoriteAlgoFeedsOrchestrator,
|
||||||
outboxRelays = followsRelays,
|
outboxRelays = followsRelays,
|
||||||
proxyRelays = proxyRelays,
|
proxyRelays = proxyRelays,
|
||||||
)
|
)
|
||||||
|
|||||||
+16
-16
@@ -18,10 +18,10 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.dvms.FavoriteDvmSnapshot
|
import com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsSnapshot
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedFlowsType
|
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedFlowsType
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavFilter
|
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavFilter
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Address
|
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
|
* 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.
|
* favorite set changes.
|
||||||
*/
|
*/
|
||||||
class AllFavoriteDvmsFeedFlow(
|
class AllFavoriteAlgoFeedsFlow(
|
||||||
val favoriteDvmAddresses: StateFlow<Set<Address>>,
|
val favoriteAlgoFeedAddresses: StateFlow<Set<Address>>,
|
||||||
val orchestrator: FavoriteDvmOrchestrator,
|
val orchestrator: FavoriteAlgoFeedsOrchestrator,
|
||||||
val outboxRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
val outboxRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
||||||
val proxyRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
val proxyRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
||||||
) : IFeedFlowsType {
|
) : IFeedFlowsType {
|
||||||
@@ -50,9 +50,9 @@ class AllFavoriteDvmsFeedFlow(
|
|||||||
): Set<NormalizedRelayUrl> = if (proxy.isNotEmpty()) proxy else outbox
|
): Set<NormalizedRelayUrl> = if (proxy.isNotEmpty()) proxy else outbox
|
||||||
|
|
||||||
private fun merge(
|
private fun merge(
|
||||||
snapshots: List<FavoriteDvmSnapshot>,
|
snapshots: List<FavoriteAlgoFeedsSnapshot>,
|
||||||
contentRelays: Set<NormalizedRelayUrl>,
|
contentRelays: Set<NormalizedRelayUrl>,
|
||||||
): AllFavoriteDvmsTopNavFilter {
|
): AllFavoriteAlgoFeedsTopNavFilter {
|
||||||
val ids = mutableSetOf<String>()
|
val ids = mutableSetOf<String>()
|
||||||
val addresses = mutableSetOf<String>()
|
val addresses = mutableSetOf<String>()
|
||||||
val listen = mutableSetOf<NormalizedRelayUrl>()
|
val listen = mutableSetOf<NormalizedRelayUrl>()
|
||||||
@@ -63,7 +63,7 @@ class AllFavoriteDvmsFeedFlow(
|
|||||||
listen += snap.responseRelays
|
listen += snap.responseRelays
|
||||||
snap.requestId?.let { requestIds += it }
|
snap.requestId?.let { requestIds += it }
|
||||||
}
|
}
|
||||||
return AllFavoriteDvmsTopNavFilter(
|
return AllFavoriteAlgoFeedsTopNavFilter(
|
||||||
acceptedIds = ids,
|
acceptedIds = ids,
|
||||||
acceptedAddresses = addresses,
|
acceptedAddresses = addresses,
|
||||||
contentRelays = contentRelays,
|
contentRelays = contentRelays,
|
||||||
@@ -72,8 +72,8 @@ class AllFavoriteDvmsFeedFlow(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun emptyFilter(contentRelays: Set<NormalizedRelayUrl>): AllFavoriteDvmsTopNavFilter =
|
private fun emptyFilter(contentRelays: Set<NormalizedRelayUrl>): AllFavoriteAlgoFeedsTopNavFilter =
|
||||||
AllFavoriteDvmsTopNavFilter(
|
AllFavoriteAlgoFeedsTopNavFilter(
|
||||||
acceptedIds = emptySet(),
|
acceptedIds = emptySet(),
|
||||||
acceptedAddresses = emptySet(),
|
acceptedAddresses = emptySet(),
|
||||||
contentRelays = contentRelays,
|
contentRelays = contentRelays,
|
||||||
@@ -83,13 +83,13 @@ class AllFavoriteDvmsFeedFlow(
|
|||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
override fun flow(): Flow<IFeedTopNavFilter> =
|
override fun flow(): Flow<IFeedTopNavFilter> =
|
||||||
favoriteDvmAddresses.flatMapLatest { addresses ->
|
favoriteAlgoFeedAddresses.flatMapLatest { addresses ->
|
||||||
if (addresses.isEmpty()) {
|
if (addresses.isEmpty()) {
|
||||||
combine(outboxRelays, proxyRelays) { outbox, proxy ->
|
combine(outboxRelays, proxyRelays) { outbox, proxy ->
|
||||||
emptyFilter(resolveContentRelays(outbox, proxy))
|
emptyFilter(resolveContentRelays(outbox, proxy))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val snapshotFlows: List<Flow<FavoriteDvmSnapshot>> = addresses.map { orchestrator.observe(it) }
|
val snapshotFlows: List<Flow<FavoriteAlgoFeedsSnapshot>> = addresses.map { orchestrator.observe(it) }
|
||||||
combine(snapshotFlows) { it.toList() }
|
combine(snapshotFlows) { it.toList() }
|
||||||
.let { merged ->
|
.let { merged ->
|
||||||
combine(merged, outboxRelays, proxyRelays) { snaps, outbox, proxy ->
|
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 contentRelays = resolveContentRelays(outboxRelays.value, proxyRelays.value)
|
||||||
val addresses = favoriteDvmAddresses.value
|
val addresses = favoriteAlgoFeedAddresses.value
|
||||||
return if (addresses.isEmpty()) {
|
return if (addresses.isEmpty()) {
|
||||||
emptyFilter(contentRelays)
|
emptyFilter(contentRelays)
|
||||||
} else {
|
} else {
|
||||||
+7
-7
@@ -18,7 +18,7 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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 androidx.compose.runtime.Immutable
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
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
|
* 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
|
* 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.
|
* request-id list carries one entry per DVM for the relay-listen subscription.
|
||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
class AllFavoriteDvmsTopNavFilter(
|
class AllFavoriteAlgoFeedsTopNavFilter(
|
||||||
val acceptedIds: Set<HexKey>,
|
val acceptedIds: Set<HexKey>,
|
||||||
val acceptedAddresses: Set<String>,
|
val acceptedAddresses: Set<String>,
|
||||||
val contentRelays: Set<NormalizedRelayUrl>,
|
val contentRelays: Set<NormalizedRelayUrl>,
|
||||||
@@ -50,13 +50,13 @@ class AllFavoriteDvmsTopNavFilter(
|
|||||||
noteEvent.id in acceptedIds ||
|
noteEvent.id in acceptedIds ||
|
||||||
(noteEvent is AddressableEvent && noteEvent.addressTag() in acceptedAddresses)
|
(noteEvent is AddressableEvent && noteEvent.addressTag() in acceptedAddresses)
|
||||||
|
|
||||||
override fun toPerRelayFlow(cache: LocalCache): Flow<FavoriteDvmTopNavPerRelayFilterSet> = MutableStateFlow(startValue(cache))
|
override fun toPerRelayFlow(cache: LocalCache): Flow<FavoriteAlgoFeedTopNavPerRelayFilterSet> = MutableStateFlow(startValue(cache))
|
||||||
|
|
||||||
override fun startValue(cache: LocalCache): FavoriteDvmTopNavPerRelayFilterSet =
|
override fun startValue(cache: LocalCache): FavoriteAlgoFeedTopNavPerRelayFilterSet =
|
||||||
FavoriteDvmTopNavPerRelayFilterSet(
|
FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
contentFetches =
|
contentFetches =
|
||||||
contentRelays.associateWith {
|
contentRelays.associateWith {
|
||||||
FavoriteDvmTopNavPerRelayFilter(
|
FavoriteAlgoFeedTopNavPerRelayFilter(
|
||||||
ids = acceptedIds,
|
ids = acceptedIds,
|
||||||
addresses = acceptedAddresses,
|
addresses = acceptedAddresses,
|
||||||
)
|
)
|
||||||
+11
-11
@@ -18,9 +18,9 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.IFeedFlowsType
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavFilter
|
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavFilter
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Address
|
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.StateFlow
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
|
|
||||||
class FavoriteDvmFeedFlow(
|
class FavoriteAlgoFeedFlow(
|
||||||
val dvmAddress: Address,
|
val feedAddress: Address,
|
||||||
val orchestrator: FavoriteDvmOrchestrator,
|
val orchestrator: FavoriteAlgoFeedsOrchestrator,
|
||||||
val outboxRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
val outboxRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
||||||
val proxyRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
val proxyRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
||||||
) : IFeedFlowsType {
|
) : IFeedFlowsType {
|
||||||
@@ -42,10 +42,10 @@ class FavoriteDvmFeedFlow(
|
|||||||
): Set<NormalizedRelayUrl> = if (proxy.isNotEmpty()) proxy else outbox
|
): Set<NormalizedRelayUrl> = if (proxy.isNotEmpty()) proxy else outbox
|
||||||
|
|
||||||
private fun buildFilter(
|
private fun buildFilter(
|
||||||
snapshot: com.vitorpamplona.amethyst.model.dvms.FavoriteDvmSnapshot,
|
snapshot: com.vitorpamplona.amethyst.model.algoFeeds.FavoriteAlgoFeedsSnapshot,
|
||||||
contentRelays: Set<NormalizedRelayUrl>,
|
contentRelays: Set<NormalizedRelayUrl>,
|
||||||
) = FavoriteDvmTopNavFilter(
|
) = FavoriteAlgoFeedTopNavFilter(
|
||||||
dvmAddress = dvmAddress,
|
feedAddress = feedAddress,
|
||||||
acceptedIds = snapshot.ids,
|
acceptedIds = snapshot.ids,
|
||||||
acceptedAddresses = snapshot.addresses,
|
acceptedAddresses = snapshot.addresses,
|
||||||
contentRelays = contentRelays,
|
contentRelays = contentRelays,
|
||||||
@@ -54,13 +54,13 @@ class FavoriteDvmFeedFlow(
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun flow(): Flow<IFeedTopNavFilter> =
|
override fun flow(): Flow<IFeedTopNavFilter> =
|
||||||
combine(orchestrator.observe(dvmAddress), outboxRelays, proxyRelays) { snap, outbox, proxy ->
|
combine(orchestrator.observe(feedAddress), outboxRelays, proxyRelays) { snap, outbox, proxy ->
|
||||||
buildFilter(snap, resolveRelays(outbox, proxy))
|
buildFilter(snap, resolveRelays(outbox, proxy))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun startValue(): FavoriteDvmTopNavFilter =
|
override fun startValue(): FavoriteAlgoFeedTopNavFilter =
|
||||||
buildFilter(
|
buildFilter(
|
||||||
snapshot = orchestrator.observe(dvmAddress).value,
|
snapshot = orchestrator.observe(feedAddress).value,
|
||||||
contentRelays = resolveRelays(outboxRelays.value, proxyRelays.value),
|
contentRelays = resolveRelays(outboxRelays.value, proxyRelays.value),
|
||||||
)
|
)
|
||||||
|
|
||||||
+9
-9
@@ -18,7 +18,7 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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 androidx.compose.runtime.Immutable
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
@@ -32,15 +32,15 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
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
|
* 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
|
* 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
|
@Immutable
|
||||||
class FavoriteDvmTopNavFilter(
|
class FavoriteAlgoFeedTopNavFilter(
|
||||||
val dvmAddress: Address,
|
val feedAddress: Address,
|
||||||
val acceptedIds: Set<HexKey>,
|
val acceptedIds: Set<HexKey>,
|
||||||
val acceptedAddresses: Set<String>,
|
val acceptedAddresses: Set<String>,
|
||||||
val contentRelays: Set<NormalizedRelayUrl>,
|
val contentRelays: Set<NormalizedRelayUrl>,
|
||||||
@@ -53,13 +53,13 @@ class FavoriteDvmTopNavFilter(
|
|||||||
noteEvent.id in acceptedIds ||
|
noteEvent.id in acceptedIds ||
|
||||||
(noteEvent is AddressableEvent && noteEvent.addressTag() in acceptedAddresses)
|
(noteEvent is AddressableEvent && noteEvent.addressTag() in acceptedAddresses)
|
||||||
|
|
||||||
override fun toPerRelayFlow(cache: LocalCache): Flow<FavoriteDvmTopNavPerRelayFilterSet> = MutableStateFlow(startValue(cache))
|
override fun toPerRelayFlow(cache: LocalCache): Flow<FavoriteAlgoFeedTopNavPerRelayFilterSet> = MutableStateFlow(startValue(cache))
|
||||||
|
|
||||||
override fun startValue(cache: LocalCache): FavoriteDvmTopNavPerRelayFilterSet =
|
override fun startValue(cache: LocalCache): FavoriteAlgoFeedTopNavPerRelayFilterSet =
|
||||||
FavoriteDvmTopNavPerRelayFilterSet(
|
FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
contentFetches =
|
contentFetches =
|
||||||
contentRelays.associateWith {
|
contentRelays.associateWith {
|
||||||
FavoriteDvmTopNavPerRelayFilter(
|
FavoriteAlgoFeedTopNavPerRelayFilter(
|
||||||
ids = acceptedIds,
|
ids = acceptedIds,
|
||||||
addresses = acceptedAddresses,
|
addresses = acceptedAddresses,
|
||||||
)
|
)
|
||||||
+2
-2
@@ -18,14 +18,14 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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 androidx.compose.runtime.Immutable
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavPerRelayFilter
|
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavPerRelayFilter
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
class FavoriteDvmTopNavPerRelayFilter(
|
class FavoriteAlgoFeedTopNavPerRelayFilter(
|
||||||
val ids: Set<HexKey>,
|
val ids: Set<HexKey>,
|
||||||
val addresses: Set<String>,
|
val addresses: Set<String>,
|
||||||
) : IFeedTopNavPerRelayFilter
|
) : IFeedTopNavPerRelayFilter
|
||||||
+5
-5
@@ -18,7 +18,7 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.amethyst.model.topNavFeeds.IFeedTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
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
|
* - [listenRelays] — the union of DVM publish relays across all active DVMs
|
||||||
* (where they will deliver future kind 6300 / 7000 events for their requests).
|
* (where they will deliver future kind 6300 / 7000 events for their requests).
|
||||||
* - [requestIds] — the set of currently-active kind-5300 request ids to listen
|
* - [requestIds] — the set of currently-active kind-5300 request ids to listen
|
||||||
* for. A single-DVM filter carries one; the merged "All favorite DVMs"
|
* for. A single feed carries one; the merged "All favorite algo feeds"
|
||||||
* filter carries one per favorite DVM.
|
* filter carries one per favorite algo feed.
|
||||||
*/
|
*/
|
||||||
class FavoriteDvmTopNavPerRelayFilterSet(
|
class FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
val contentFetches: Map<NormalizedRelayUrl, FavoriteDvmTopNavPerRelayFilter>,
|
val contentFetches: Map<NormalizedRelayUrl, FavoriteAlgoFeedTopNavPerRelayFilter>,
|
||||||
val listenRelays: Set<NormalizedRelayUrl>,
|
val listenRelays: Set<NormalizedRelayUrl>,
|
||||||
val requestIds: Set<HexKey>,
|
val requestIds: Set<HexKey>,
|
||||||
) : IFeedTopNavPerRelayFilterSet
|
) : IFeedTopNavPerRelayFilterSet
|
||||||
@@ -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.discover.nip99Classifieds.NewProductScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.drafts.DraftListScreen
|
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.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.followPacks.feed.FollowPackFeedScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.GeoHashPostScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.GeoHashPostScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.GeoHashScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.geohash.GeoHashScreen
|
||||||
@@ -278,7 +278,7 @@ fun BuildNavigation(
|
|||||||
composableFromEnd<Route.RequestToVanish> { RequestToVanishScreen(accountViewModel, nav) }
|
composableFromEnd<Route.RequestToVanish> { RequestToVanishScreen(accountViewModel, nav) }
|
||||||
composableFromEnd<Route.VanishEvents> { VanishEventsScreen(accountViewModel, nav) }
|
composableFromEnd<Route.VanishEvents> { VanishEventsScreen(accountViewModel, nav) }
|
||||||
composableFromEndArgs<Route.EditMediaServers> { AllMediaServersScreen(accountViewModel, nav) }
|
composableFromEndArgs<Route.EditMediaServers> { AllMediaServersScreen(accountViewModel, nav) }
|
||||||
composableFromEnd<Route.EditFavoriteDvms> { FavoriteDvmListScreen(accountViewModel, nav) }
|
composableFromEnd<Route.EditFavoriteAlgoFeeds> { FavoriteAlgoFeedsListScreen(accountViewModel, nav) }
|
||||||
composableFromEnd<Route.EditPaymentTargets> { PaymentTargetsScreen(accountViewModel, nav) }
|
composableFromEnd<Route.EditPaymentTargets> { PaymentTargetsScreen(accountViewModel, nav) }
|
||||||
composableFromEndArgs<Route.UpdateReactionType> { UpdateReactionTypeScreen(accountViewModel, nav) }
|
composableFromEndArgs<Route.UpdateReactionType> { UpdateReactionTypeScreen(accountViewModel, nav) }
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ sealed class Route {
|
|||||||
|
|
||||||
@Serializable object EditMediaServers : Route()
|
@Serializable object EditMediaServers : Route()
|
||||||
|
|
||||||
@Serializable object EditFavoriteDvms : Route()
|
@Serializable object EditFavoriteAlgoFeeds : Route()
|
||||||
|
|
||||||
@Serializable object EditPaymentTargets : Route()
|
@Serializable object EditPaymentTargets : Route()
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -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.components.LoadingAnimation
|
||||||
import com.vitorpamplona.amethyst.ui.note.creators.location.LoadCityName
|
import com.vitorpamplona.amethyst.ui.note.creators.location.LoadCityName
|
||||||
import com.vitorpamplona.amethyst.ui.screen.CommunityName
|
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.FeedDefinition
|
||||||
import com.vitorpamplona.amethyst.ui.screen.GeoHashName
|
import com.vitorpamplona.amethyst.ui.screen.GeoHashName
|
||||||
import com.vitorpamplona.amethyst.ui.screen.HashtagName
|
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 noteState by observeNote(option.note, accountViewModel)
|
||||||
val name =
|
val name =
|
||||||
(noteState.note.event as? AppDefinitionEvent)
|
(noteState.note.event as? AppDefinitionEvent)
|
||||||
@@ -419,7 +419,7 @@ private fun groupFeedDefinitions(options: ImmutableList<FeedDefinition>): Map<Fe
|
|||||||
FeedGroup.LOCATIONS
|
FeedGroup.LOCATIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
is FavoriteDvmName -> {
|
is FavoriteAlgoFeedName -> {
|
||||||
FeedGroup.DVMS
|
FeedGroup.DVMS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@ private fun groupFeedDefinitions(options: ImmutableList<FeedDefinition>): Map<Fe
|
|||||||
when (entry.item.code) {
|
when (entry.item.code) {
|
||||||
is TopFilter.AroundMe -> FeedGroup.LOCATIONS
|
is TopFilter.AroundMe -> FeedGroup.LOCATIONS
|
||||||
is TopFilter.Global -> FeedGroup.RELAYS
|
is TopFilter.Global -> FeedGroup.RELAYS
|
||||||
is TopFilter.AllFavoriteDvms -> FeedGroup.DVMS
|
is TopFilter.AllFavoriteAlgoFeeds -> FeedGroup.DVMS
|
||||||
else -> FeedGroup.FEEDS
|
else -> FeedGroup.FEEDS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -592,11 +592,11 @@ private fun FeedIcon(
|
|||||||
Icons.AutoMirrored.Outlined.ViewList
|
Icons.AutoMirrored.Outlined.ViewList
|
||||||
}
|
}
|
||||||
|
|
||||||
is TopFilter.FavoriteDvm -> {
|
is TopFilter.FavoriteAlgoFeed -> {
|
||||||
Icons.Outlined.AutoAwesome
|
Icons.Outlined.AutoAwesome
|
||||||
}
|
}
|
||||||
|
|
||||||
is TopFilter.AllFavoriteDvms -> {
|
is TopFilter.AllFavoriteAlgoFeeds -> {
|
||||||
Icons.Outlined.AutoAwesome
|
Icons.Outlined.AutoAwesome
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,7 +606,7 @@ private fun FeedIcon(
|
|||||||
is RelayName -> Icons.Outlined.Storage
|
is RelayName -> Icons.Outlined.Storage
|
||||||
is CommunityName -> Icons.Outlined.Groups
|
is CommunityName -> Icons.Outlined.Groups
|
||||||
is PeopleListName -> Icons.AutoMirrored.Outlined.ViewList
|
is PeopleListName -> Icons.AutoMirrored.Outlined.ViewList
|
||||||
is FavoriteDvmName -> Icons.Outlined.AutoAwesome
|
is FavoriteAlgoFeedName -> Icons.Outlined.AutoAwesome
|
||||||
else -> Icons.Outlined.Person
|
else -> Icons.Outlined.Person
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ class TopNavFilterState(
|
|||||||
name = ResourceName(R.string.follow_list_chess),
|
name = ResourceName(R.string.follow_list_chess),
|
||||||
)
|
)
|
||||||
|
|
||||||
val allFavoriteDvmsFollow =
|
val allFavoriteAlgoFeedsFollow =
|
||||||
FeedDefinition(
|
FeedDefinition(
|
||||||
code = TopFilter.AllFavoriteDvms,
|
code = TopFilter.AllFavoriteAlgoFeeds,
|
||||||
name = ResourceName(R.string.follow_list_all_favorite_dvms),
|
name = ResourceName(R.string.follow_list_all_favorite_dvms),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ class TopNavFilterState(
|
|||||||
geotagList: Set<String>,
|
geotagList: Set<String>,
|
||||||
communityList: List<AddressableNote>,
|
communityList: List<AddressableNote>,
|
||||||
relayList: Set<NormalizedRelayUrl>,
|
relayList: Set<NormalizedRelayUrl>,
|
||||||
favoriteDvmList: List<AddressableNote>,
|
favoriteAlgoFeedsList: List<AddressableNote>,
|
||||||
): List<FeedDefinition> {
|
): List<FeedDefinition> {
|
||||||
val hashtags =
|
val hashtags =
|
||||||
hashtagList.map {
|
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
|
// that the AppDefinitionEvent advertises kind 5300. Don't re-check here: on
|
||||||
// cold start the AppDefinitionEvent may not be in cache yet, and dropping
|
// 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
|
// in the spinner (user sees "Select an option" while the banner fires the
|
||||||
// RPC — the bug we had before this change).
|
// RPC — the bug we had before this change).
|
||||||
val favoriteDvms =
|
val favoriteAlgoFeeds =
|
||||||
favoriteDvmList.map { dvmNote ->
|
favoriteAlgoFeedsList.map { feedNote ->
|
||||||
FeedDefinition(
|
FeedDefinition(
|
||||||
TopFilter.FavoriteDvm(dvmNote.address),
|
TopFilter.FavoriteAlgoFeed(feedNote.address),
|
||||||
FavoriteDvmName(dvmNote),
|
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.
|
// real favorite to merge; otherwise the chip opens to an empty feed.
|
||||||
val allFavorites =
|
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)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@@ -210,7 +210,7 @@ class TopNavFilterState(
|
|||||||
account.geohashList.flow,
|
account.geohashList.flow,
|
||||||
account.communityList.flowNotes,
|
account.communityList.flowNotes,
|
||||||
account.relayFeedsList.flow,
|
account.relayFeedsList.flow,
|
||||||
account.favoriteDvmList.flowNotes,
|
account.favoriteAlgoFeedsList.flowNotes,
|
||||||
::mergeInterests,
|
::mergeInterests,
|
||||||
).onStart {
|
).onStart {
|
||||||
emit(
|
emit(
|
||||||
@@ -219,7 +219,7 @@ class TopNavFilterState(
|
|||||||
account.geohashList.flow.value,
|
account.geohashList.flow.value,
|
||||||
account.communityList.flowNotes.value,
|
account.communityList.flowNotes.value,
|
||||||
account.relayFeedsList.flow.value,
|
account.relayFeedsList.flow.value,
|
||||||
account.favoriteDvmList.flowNotes.value,
|
account.favoriteAlgoFeedsList.flowNotes.value,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -328,7 +328,7 @@ class CommunityName(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
class FavoriteDvmName(
|
class FavoriteAlgoFeedName(
|
||||||
val note: AddressableNote,
|
val note: AddressableNote,
|
||||||
) : Name() {
|
) : Name() {
|
||||||
override fun name(): String =
|
override fun name(): String =
|
||||||
|
|||||||
+3
-3
@@ -1089,11 +1089,11 @@ class AccountViewModel(
|
|||||||
|
|
||||||
fun unfollowHashtag(tag: String) = launchSigner { account.unfollowHashtag(tag) }
|
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) }
|
fun followRelayFeed(url: NormalizedRelayUrl) = launchSigner { account.followRelayFeed(url) }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -49,7 +49,7 @@ import com.vitorpamplona.amethyst.ui.note.LikeReaction
|
|||||||
import com.vitorpamplona.amethyst.ui.note.ZapReaction
|
import com.vitorpamplona.amethyst.ui.note.ZapReaction
|
||||||
import com.vitorpamplona.amethyst.ui.note.elements.BannerImage
|
import com.vitorpamplona.amethyst.ui.note.elements.BannerImage
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
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.screen.loggedIn.dvms.observeAppDefinition
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HalfTopPadding
|
import com.vitorpamplona.amethyst.ui.theme.HalfTopPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.RowColSpacing5dp
|
import com.vitorpamplona.amethyst.ui.theme.RowColSpacing5dp
|
||||||
@@ -117,7 +117,7 @@ fun RenderContentDVMThumb(
|
|||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
)
|
)
|
||||||
if (baseNote is AddressableNote) {
|
if (baseNote is AddressableNote) {
|
||||||
FavoriteDvmToggle(
|
FavoriteAlgoFeedToggle(
|
||||||
appDefinitionNote = baseNote,
|
appDefinitionNote = baseNote,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ fun DvmTopBar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
addressableNote?.let { target ->
|
addressableNote?.let { target ->
|
||||||
FavoriteDvmToggle(
|
FavoriteAlgoFeedToggle(
|
||||||
appDefinitionNote = target,
|
appDefinitionNote = target,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
)
|
)
|
||||||
|
|||||||
+4
-4
@@ -52,7 +52,7 @@ import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDi
|
|||||||
* a 6300 reply that never comes.
|
* a 6300 reply that never comes.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun FavoriteDvmToggle(
|
fun FavoriteAlgoFeedToggle(
|
||||||
appDefinitionNote: AddressableNote,
|
appDefinitionNote: AddressableNote,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
@@ -65,7 +65,7 @@ fun FavoriteDvmToggle(
|
|||||||
|
|
||||||
if (!supportsContentDiscovery) return
|
if (!supportsContentDiscovery) return
|
||||||
|
|
||||||
val favorites by accountViewModel.account.favoriteDvmList.flow
|
val favorites by accountViewModel.account.favoriteAlgoFeedsList.flow
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
val isFavorite = favorites.contains(appDefinitionNote.address)
|
val isFavorite = favorites.contains(appDefinitionNote.address)
|
||||||
@@ -74,9 +74,9 @@ fun FavoriteDvmToggle(
|
|||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onClick = {
|
onClick = {
|
||||||
if (isFavorite) {
|
if (isFavorite) {
|
||||||
accountViewModel.unfollowFavoriteDvm(appDefinitionNote.address)
|
accountViewModel.unfollowFavoriteAlgoFeed(appDefinitionNote.address)
|
||||||
} else {
|
} else {
|
||||||
accountViewModel.followFavoriteDvm(
|
accountViewModel.followFavoriteAlgoFeed(
|
||||||
AddressBookmark(
|
AddressBookmark(
|
||||||
address = appDefinitionNote.address,
|
address = appDefinitionNote.address,
|
||||||
relayHint = appDefinitionNote.relayHintUrl(),
|
relayHint = appDefinitionNote.relayHintUrl(),
|
||||||
+16
-16
@@ -70,7 +70,7 @@ import com.vitorpamplona.amethyst.ui.theme.grayText
|
|||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun FavoriteDvmListScreen(
|
fun FavoriteAlgoFeedsListScreen(
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
@@ -101,17 +101,17 @@ fun FavoriteDvmListScreen(
|
|||||||
color = MaterialTheme.colorScheme.grayText,
|
color = MaterialTheme.colorScheme.grayText,
|
||||||
)
|
)
|
||||||
|
|
||||||
FavoriteDvmList(accountViewModel, nav)
|
FavoriteAlgoFeedList(accountViewModel, nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun FavoriteDvmList(
|
private fun FavoriteAlgoFeedList(
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val favorites by accountViewModel.account.favoriteDvmList.flowNotes
|
val favorites by accountViewModel.account.favoriteAlgoFeedsList.flowNotes
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
if (favorites.isEmpty()) {
|
if (favorites.isEmpty()) {
|
||||||
@@ -136,12 +136,12 @@ private fun FavoriteDvmList(
|
|||||||
items(
|
items(
|
||||||
items = favorites,
|
items = favorites,
|
||||||
key = { it.address.toValue() },
|
key = { it.address.toValue() },
|
||||||
) { dvmNote ->
|
) { feedNote ->
|
||||||
FavoriteDvmRow(
|
FavoriteAlgoFeedRow(
|
||||||
dvmNote = dvmNote,
|
feedNote = feedNote,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onOpen = { nav.nav(Route.ContentDiscovery(dvmNote.idHex)) },
|
onOpen = { nav.nav(Route.ContentDiscovery(feedNote.idHex)) },
|
||||||
onRemove = { accountViewModel.unfollowFavoriteDvm(dvmNote.address) },
|
onRemove = { accountViewModel.unfollowFavoriteAlgoFeed(feedNote.address) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,13 +149,13 @@ private fun FavoriteDvmList(
|
|||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun FavoriteDvmRow(
|
private fun FavoriteAlgoFeedRow(
|
||||||
dvmNote: AddressableNote,
|
feedNote: AddressableNote,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
onOpen: () -> Unit,
|
onOpen: () -> Unit,
|
||||||
onRemove: () -> Unit,
|
onRemove: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val card = observeAppDefinition(dvmNote, accountViewModel)
|
val card = observeAppDefinition(feedNote, accountViewModel)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier =
|
modifier =
|
||||||
@@ -175,19 +175,19 @@ private fun FavoriteDvmRow(
|
|||||||
loadedImageModifier = SimpleImage35Modifier,
|
loadedImageModifier = SimpleImage35Modifier,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onLoadingBackground = {
|
onLoadingBackground = {
|
||||||
dvmNote.author?.let { author ->
|
feedNote.author?.let { author ->
|
||||||
BannerImage(author, SimpleImage35Modifier, accountViewModel)
|
BannerImage(author, SimpleImage35Modifier, accountViewModel)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError = {
|
onError = {
|
||||||
dvmNote.author?.let { author ->
|
feedNote.author?.let { author ->
|
||||||
BannerImage(author, SimpleImage35Modifier, accountViewModel)
|
BannerImage(author, SimpleImage35Modifier, accountViewModel)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
dvmNote.author?.let { author ->
|
feedNote.author?.let { author ->
|
||||||
BannerImage(author, SimpleImage35Modifier, accountViewModel)
|
BannerImage(author, SimpleImage35Modifier, accountViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ private fun FavoriteDvmRow(
|
|||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = card.name.ifBlank { dvmNote.dTag() },
|
text = card.name.ifBlank { feedNote.dTag() },
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
+18
-18
@@ -42,7 +42,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.TopFilter
|
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.service.relayClient.reqCommand.event.observeNoteAndMap
|
||||||
import com.vitorpamplona.amethyst.ui.components.LoadNote
|
import com.vitorpamplona.amethyst.ui.components.LoadNote
|
||||||
import com.vitorpamplona.amethyst.ui.components.LoadingAnimation
|
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
|
import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeDvmStatusBanner(
|
fun HomeAlgoFeedStatusBanner(
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
@@ -64,31 +64,31 @@ fun HomeDvmStatusBanner(
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
when (val filter = topFilter) {
|
when (val filter = topFilter) {
|
||||||
is TopFilter.FavoriteDvm -> SingleDvmBanner(filter, accountViewModel, nav, modifier)
|
is TopFilter.FavoriteAlgoFeed -> SingleAlgoFeedBanner(filter, accountViewModel, nav, modifier)
|
||||||
is TopFilter.AllFavoriteDvms -> AllFavoriteDvmsBanner(accountViewModel, modifier)
|
is TopFilter.AllFavoriteAlgoFeeds -> AllFavoriteAlgoFeedsBanner(accountViewModel, modifier)
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SingleDvmBanner(
|
private fun SingleAlgoFeedBanner(
|
||||||
favDvm: TopFilter.FavoriteDvm,
|
favFeed: TopFilter.FavoriteAlgoFeed,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val snapshot by accountViewModel.account.favoriteDvmOrchestrator
|
val snapshot by accountViewModel.account.favoriteAlgoFeedsOrchestrator
|
||||||
.observe(favDvm.address)
|
.observe(favFeed.address)
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
// Hide the banner when the feed is already populated.
|
// Hide the banner when the feed is already populated.
|
||||||
if (snapshot.ids.isNotEmpty() || snapshot.addresses.isNotEmpty()) return
|
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
|
val resolvedName by
|
||||||
observeNoteAndMap(dvmNote ?: return@LoadNote, accountViewModel) { note ->
|
observeNoteAndMap(feedNote ?: return@LoadNote, accountViewModel) { note ->
|
||||||
(note.event as? AppDefinitionEvent)
|
(note.event as? AppDefinitionEvent)
|
||||||
?.appMetaData()
|
?.appMetaData()
|
||||||
?.name
|
?.name
|
||||||
@@ -107,7 +107,7 @@ private fun SingleDvmBanner(
|
|||||||
showSpinner = false,
|
showSpinner = false,
|
||||||
)
|
)
|
||||||
Spacer(modifier = StdVertSpacer)
|
Spacer(modifier = StdVertSpacer)
|
||||||
RetryButton { accountViewModel.refreshFavoriteDvm(favDvm.address) }
|
RetryButton { accountViewModel.refreshFavoriteAlgoFeed(favFeed.address) }
|
||||||
}
|
}
|
||||||
|
|
||||||
status?.code == "payment-required" -> {
|
status?.code == "payment-required" -> {
|
||||||
@@ -144,7 +144,7 @@ private fun SingleDvmBanner(
|
|||||||
showSpinner = false,
|
showSpinner = false,
|
||||||
)
|
)
|
||||||
Spacer(modifier = StdVertSpacer)
|
Spacer(modifier = StdVertSpacer)
|
||||||
RetryButton { accountViewModel.refreshFavoriteDvm(favDvm.address) }
|
RetryButton { accountViewModel.refreshFavoriteAlgoFeed(favFeed.address) }
|
||||||
}
|
}
|
||||||
|
|
||||||
status?.code == "processing" -> {
|
status?.code == "processing" -> {
|
||||||
@@ -169,11 +169,11 @@ private fun SingleDvmBanner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AllFavoriteDvmsBanner(
|
private fun AllFavoriteAlgoFeedsBanner(
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val addresses by accountViewModel.account.favoriteDvmList.flow
|
val addresses by accountViewModel.account.favoriteAlgoFeedsList.flow
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
if (addresses.isEmpty()) return
|
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
|
// 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
|
// 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.
|
// feed; only error out when every one of them has errored.
|
||||||
val snapshots: List<FavoriteDvmSnapshot> =
|
val snapshots: List<FavoriteAlgoFeedsSnapshot> =
|
||||||
addresses.map { address ->
|
addresses.map { address ->
|
||||||
val snap by accountViewModel.account.favoriteDvmOrchestrator
|
val snap by accountViewModel.account.favoriteAlgoFeedsOrchestrator
|
||||||
.observe(address)
|
.observe(address)
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
snap
|
snap
|
||||||
@@ -202,7 +202,7 @@ private fun AllFavoriteDvmsBanner(
|
|||||||
)
|
)
|
||||||
Spacer(modifier = StdVertSpacer)
|
Spacer(modifier = StdVertSpacer)
|
||||||
RetryButton {
|
RetryButton {
|
||||||
addresses.forEach { accountViewModel.refreshFavoriteDvm(it) }
|
addresses.forEach { accountViewModel.refreshFavoriteAlgoFeed(it) }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BannerMessageRow(
|
BannerMessageRow(
|
||||||
+4
-4
@@ -240,7 +240,7 @@ private fun HomePages(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeDvmStatusBanner(
|
HomeAlgoFeedStatusBanner(
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
modifier = Modifier.align(Alignment.TopCenter),
|
modifier = Modifier.align(Alignment.TopCenter),
|
||||||
@@ -300,7 +300,7 @@ fun HomeFeeds(
|
|||||||
) {
|
) {
|
||||||
val activeFilter by accountViewModel.account.settings.defaultHomeFollowList
|
val activeFilter by accountViewModel.account.settings.defaultHomeFollowList
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
val favoriteDvmAddresses by accountViewModel.account.favoriteDvmList.flow
|
val favoriteAlgoFeedAddresses by accountViewModel.account.favoriteAlgoFeedsList.flow
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
val onRefresh: () -> Unit = {
|
val onRefresh: () -> Unit = {
|
||||||
@@ -308,8 +308,8 @@ fun HomeFeeds(
|
|||||||
// Swiping down on Home should also re-issue the kind-5300 request(s) so the
|
// 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.
|
// DVM(s) produce fresh feeds, not just re-render whatever's cached.
|
||||||
when (val filter = activeFilter) {
|
when (val filter = activeFilter) {
|
||||||
is TopFilter.FavoriteDvm -> accountViewModel.refreshFavoriteDvm(filter.address)
|
is TopFilter.FavoriteAlgoFeed -> accountViewModel.refreshFavoriteAlgoFeed(filter.address)
|
||||||
is TopFilter.AllFavoriteDvms -> favoriteDvmAddresses.forEach { accountViewModel.refreshFavoriteDvm(it) }
|
is TopFilter.AllFavoriteAlgoFeeds -> favoriteAlgoFeedAddresses.forEach { accountViewModel.refreshFavoriteAlgoFeed(it) }
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.model.User
|
|||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet
|
import com.vitorpamplona.amethyst.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet
|
import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.LocationTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.chess.ChessTopNavPerRelayFilterSet
|
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.global.GlobalTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet
|
import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.allcommunities.AllCommunitiesTopNavPerRelayFilterSet
|
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.nip64Chess.filterHomePostsByChess
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.nip72Communities.filterHomePostsByAllCommunities
|
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.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.INostrClient
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription
|
import com.vitorpamplona.quartz.nip01Core.relay.client.subscriptions.Subscription
|
||||||
@@ -76,7 +76,7 @@ class HomeOutboxEventsEoseManager(
|
|||||||
is MutedAuthorsTopNavPerRelayFilterSet -> filterHomePostsByAuthors(feedSettings, since, newThreadSince, repliesSince)
|
is MutedAuthorsTopNavPerRelayFilterSet -> filterHomePostsByAuthors(feedSettings, since, newThreadSince, repliesSince)
|
||||||
is RelayTopNavPerRelayFilterSet -> filterHomePostsByRelay(feedSettings, since, newThreadSince, repliesSince)
|
is RelayTopNavPerRelayFilterSet -> filterHomePostsByRelay(feedSettings, since, newThreadSince, repliesSince)
|
||||||
is SingleCommunityTopNavPerRelayFilterSet -> filterHomePostsByCommunity(feedSettings, since, newThreadSince)
|
is SingleCommunityTopNavPerRelayFilterSet -> filterHomePostsByCommunity(feedSettings, since, newThreadSince)
|
||||||
is FavoriteDvmTopNavPerRelayFilterSet -> filterHomePostsByDvmIds(feedSettings, since, newThreadSince)
|
is FavoriteAlgoFeedTopNavPerRelayFilterSet -> filterHomePostsByAlgoFeedIds(feedSettings, since, newThreadSince)
|
||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -18,10 +18,10 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilter
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmTopNavPerRelayFilterSet
|
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
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
|
* never publishes responses on the user's outbox, so listening anywhere else
|
||||||
* would silently miss them.
|
* would silently miss them.
|
||||||
*/
|
*/
|
||||||
fun filterHomePostsByDvmIds(
|
fun filterHomePostsByAlgoFeedIds(
|
||||||
set: FavoriteDvmTopNavPerRelayFilterSet,
|
set: FavoriteAlgoFeedTopNavPerRelayFilterSet,
|
||||||
@Suppress("UNUSED_PARAMETER") since: SincePerRelayMap?,
|
@Suppress("UNUSED_PARAMETER") since: SincePerRelayMap?,
|
||||||
@Suppress("UNUSED_PARAMETER") defaultSince: Long?,
|
@Suppress("UNUSED_PARAMETER") defaultSince: Long?,
|
||||||
): List<RelayBasedFilter> {
|
): List<RelayBasedFilter> {
|
||||||
@@ -68,7 +68,7 @@ fun filterHomePostsByDvmIds(
|
|||||||
|
|
||||||
private fun contentFetchFilters(
|
private fun contentFetchFilters(
|
||||||
relay: NormalizedRelayUrl,
|
relay: NormalizedRelayUrl,
|
||||||
filter: FavoriteDvmTopNavPerRelayFilter,
|
filter: FavoriteAlgoFeedTopNavPerRelayFilter,
|
||||||
): List<RelayBasedFilter> {
|
): List<RelayBasedFilter> {
|
||||||
val out = mutableListOf<RelayBasedFilter>()
|
val out = mutableListOf<RelayBasedFilter>()
|
||||||
|
|
||||||
+1
-1
@@ -127,7 +127,7 @@ fun AllSettingsScreen(
|
|||||||
title = R.string.favorite_dvms_title,
|
title = R.string.favorite_dvms_title,
|
||||||
icon = Icons.Outlined.AutoAwesome,
|
icon = Icons.Outlined.AutoAwesome,
|
||||||
tint = tint,
|
tint = tint,
|
||||||
onClick = { nav.nav(Route.EditFavoriteDvms) },
|
onClick = { nav.nav(Route.EditFavoriteAlgoFeeds) },
|
||||||
)
|
)
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
SettingsNavigationRow(
|
SettingsNavigationRow(
|
||||||
|
|||||||
+13
-13
@@ -18,7 +18,7 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.nip01Core.core.Address
|
||||||
import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
|
import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
|
||||||
@@ -27,7 +27,7 @@ import org.junit.Assert.assertFalse
|
|||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
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 textNote(id: String) = TextNoteEvent(id = id, pubKey = "a".repeat(64), createdAt = 1, tags = emptyArray(), content = "", sig = "x".repeat(128))
|
||||||
|
|
||||||
private fun longFormNote(
|
private fun longFormNote(
|
||||||
@@ -47,8 +47,8 @@ class FavoriteDvmTopNavFilterTest {
|
|||||||
@Test
|
@Test
|
||||||
fun matchesNoteWhoseIdIsInAcceptedSet() {
|
fun matchesNoteWhoseIdIsInAcceptedSet() {
|
||||||
val filter =
|
val filter =
|
||||||
FavoriteDvmTopNavFilter(
|
FavoriteAlgoFeedTopNavFilter(
|
||||||
dvmAddress = dvmAddress,
|
feedAddress = dvmAddress,
|
||||||
acceptedIds = setOf("1".repeat(64)),
|
acceptedIds = setOf("1".repeat(64)),
|
||||||
acceptedAddresses = emptySet(),
|
acceptedAddresses = emptySet(),
|
||||||
contentRelays = emptySet(),
|
contentRelays = emptySet(),
|
||||||
@@ -62,8 +62,8 @@ class FavoriteDvmTopNavFilterTest {
|
|||||||
@Test
|
@Test
|
||||||
fun rejectsNoteNotInAcceptedSet() {
|
fun rejectsNoteNotInAcceptedSet() {
|
||||||
val filter =
|
val filter =
|
||||||
FavoriteDvmTopNavFilter(
|
FavoriteAlgoFeedTopNavFilter(
|
||||||
dvmAddress = dvmAddress,
|
feedAddress = dvmAddress,
|
||||||
acceptedIds = setOf("1".repeat(64)),
|
acceptedIds = setOf("1".repeat(64)),
|
||||||
acceptedAddresses = emptySet(),
|
acceptedAddresses = emptySet(),
|
||||||
contentRelays = emptySet(),
|
contentRelays = emptySet(),
|
||||||
@@ -81,8 +81,8 @@ class FavoriteDvmTopNavFilterTest {
|
|||||||
val articleAddress = "30023:$articleAuthor:$articleDTag"
|
val articleAddress = "30023:$articleAuthor:$articleDTag"
|
||||||
|
|
||||||
val filter =
|
val filter =
|
||||||
FavoriteDvmTopNavFilter(
|
FavoriteAlgoFeedTopNavFilter(
|
||||||
dvmAddress = dvmAddress,
|
feedAddress = dvmAddress,
|
||||||
acceptedIds = emptySet(),
|
acceptedIds = emptySet(),
|
||||||
acceptedAddresses = setOf(articleAddress),
|
acceptedAddresses = setOf(articleAddress),
|
||||||
contentRelays = emptySet(),
|
contentRelays = emptySet(),
|
||||||
@@ -96,8 +96,8 @@ class FavoriteDvmTopNavFilterTest {
|
|||||||
@Test
|
@Test
|
||||||
fun nullRequestIdCollapsesToEmptyRequestIdsInFilterSet() {
|
fun nullRequestIdCollapsesToEmptyRequestIdsInFilterSet() {
|
||||||
val filter =
|
val filter =
|
||||||
FavoriteDvmTopNavFilter(
|
FavoriteAlgoFeedTopNavFilter(
|
||||||
dvmAddress = dvmAddress,
|
feedAddress = dvmAddress,
|
||||||
acceptedIds = emptySet(),
|
acceptedIds = emptySet(),
|
||||||
acceptedAddresses = emptySet(),
|
acceptedAddresses = emptySet(),
|
||||||
contentRelays = emptySet(),
|
contentRelays = emptySet(),
|
||||||
@@ -106,7 +106,7 @@ class FavoriteDvmTopNavFilterTest {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// passing a LocalCache is only needed because the method demands it;
|
// 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)
|
val set = filter.startValue(com.vitorpamplona.amethyst.model.LocalCache)
|
||||||
assertTrue(set.requestIds.isEmpty())
|
assertTrue(set.requestIds.isEmpty())
|
||||||
}
|
}
|
||||||
@@ -114,8 +114,8 @@ class FavoriteDvmTopNavFilterTest {
|
|||||||
@Test
|
@Test
|
||||||
fun nonNullRequestIdProducesSingletonInFilterSet() {
|
fun nonNullRequestIdProducesSingletonInFilterSet() {
|
||||||
val filter =
|
val filter =
|
||||||
FavoriteDvmTopNavFilter(
|
FavoriteAlgoFeedTopNavFilter(
|
||||||
dvmAddress = dvmAddress,
|
feedAddress = dvmAddress,
|
||||||
acceptedIds = emptySet(),
|
acceptedIds = emptySet(),
|
||||||
acceptedAddresses = emptySet(),
|
acceptedAddresses = emptySet(),
|
||||||
contentRelays = emptySet(),
|
contentRelays = emptySet(),
|
||||||
+16
-16
@@ -18,10 +18,10 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* 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.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilter
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteDvm.FavoriteDvmTopNavPerRelayFilterSet
|
import com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
||||||
import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent
|
import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent
|
||||||
import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent
|
import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent
|
||||||
@@ -30,34 +30,34 @@ import org.junit.Assert.assertNotNull
|
|||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class FilterHomePostsByDvmIdsTest {
|
class FilterHomePostsByAlgoFeedIdsTest {
|
||||||
private val userRelay = RelayUrlNormalizer.normalizeOrNull("wss://user.example/")!!
|
private val userRelay = RelayUrlNormalizer.normalizeOrNull("wss://user.example/")!!
|
||||||
private val dvmRelay = RelayUrlNormalizer.normalizeOrNull("wss://dvm.example/")!!
|
private val dvmRelay = RelayUrlNormalizer.normalizeOrNull("wss://dvm.example/")!!
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun emptyFilterSetProducesNoRequests() {
|
fun emptyFilterSetProducesNoRequests() {
|
||||||
val set =
|
val set =
|
||||||
FavoriteDvmTopNavPerRelayFilterSet(
|
FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
contentFetches = emptyMap(),
|
contentFetches = emptyMap(),
|
||||||
listenRelays = emptySet(),
|
listenRelays = emptySet(),
|
||||||
requestIds = emptySet(),
|
requestIds = emptySet(),
|
||||||
)
|
)
|
||||||
|
|
||||||
assertTrue(filterHomePostsByDvmIds(set, since = null, defaultSince = null).isEmpty())
|
assertTrue(filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null).isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun contentFetchIssuedOnUserRelayWithIdsFilter() {
|
fun contentFetchIssuedOnUserRelayWithIdsFilter() {
|
||||||
val ids = setOf("a".repeat(64), "b".repeat(64))
|
val ids = setOf("a".repeat(64), "b".repeat(64))
|
||||||
val set =
|
val set =
|
||||||
FavoriteDvmTopNavPerRelayFilterSet(
|
FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
contentFetches =
|
contentFetches =
|
||||||
mapOf(userRelay to FavoriteDvmTopNavPerRelayFilter(ids = ids, addresses = emptySet())),
|
mapOf(userRelay to FavoriteAlgoFeedTopNavPerRelayFilter(ids = ids, addresses = emptySet())),
|
||||||
listenRelays = emptySet(),
|
listenRelays = emptySet(),
|
||||||
requestIds = emptySet(),
|
requestIds = emptySet(),
|
||||||
)
|
)
|
||||||
|
|
||||||
val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null)
|
val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null)
|
||||||
|
|
||||||
assertEquals(1, filters.size)
|
assertEquals(1, filters.size)
|
||||||
val single = filters.single()
|
val single = filters.single()
|
||||||
@@ -71,13 +71,13 @@ class FilterHomePostsByDvmIdsTest {
|
|||||||
fun listenFilterIssuedOnDvmRelayWithKinds6300And7000() {
|
fun listenFilterIssuedOnDvmRelayWithKinds6300And7000() {
|
||||||
val requestId = "9".repeat(64)
|
val requestId = "9".repeat(64)
|
||||||
val set =
|
val set =
|
||||||
FavoriteDvmTopNavPerRelayFilterSet(
|
FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
contentFetches = emptyMap(),
|
contentFetches = emptyMap(),
|
||||||
listenRelays = setOf(dvmRelay),
|
listenRelays = setOf(dvmRelay),
|
||||||
requestIds = setOf(requestId),
|
requestIds = setOf(requestId),
|
||||||
)
|
)
|
||||||
|
|
||||||
val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null)
|
val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null)
|
||||||
|
|
||||||
assertEquals(1, filters.size)
|
assertEquals(1, filters.size)
|
||||||
val listen = filters.single()
|
val listen = filters.single()
|
||||||
@@ -96,13 +96,13 @@ class FilterHomePostsByDvmIdsTest {
|
|||||||
val req1 = "1".repeat(64)
|
val req1 = "1".repeat(64)
|
||||||
val req2 = "2".repeat(64)
|
val req2 = "2".repeat(64)
|
||||||
val set =
|
val set =
|
||||||
FavoriteDvmTopNavPerRelayFilterSet(
|
FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
contentFetches = emptyMap(),
|
contentFetches = emptyMap(),
|
||||||
listenRelays = setOf(dvmRelay),
|
listenRelays = setOf(dvmRelay),
|
||||||
requestIds = setOf(req1, req2),
|
requestIds = setOf(req1, req2),
|
||||||
)
|
)
|
||||||
|
|
||||||
val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null)
|
val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null)
|
||||||
|
|
||||||
assertEquals(1, filters.size)
|
assertEquals(1, filters.size)
|
||||||
val eTag =
|
val eTag =
|
||||||
@@ -120,14 +120,14 @@ class FilterHomePostsByDvmIdsTest {
|
|||||||
val ids = setOf("a".repeat(64))
|
val ids = setOf("a".repeat(64))
|
||||||
val requestId = "9".repeat(64)
|
val requestId = "9".repeat(64)
|
||||||
val set =
|
val set =
|
||||||
FavoriteDvmTopNavPerRelayFilterSet(
|
FavoriteAlgoFeedTopNavPerRelayFilterSet(
|
||||||
contentFetches =
|
contentFetches =
|
||||||
mapOf(userRelay to FavoriteDvmTopNavPerRelayFilter(ids = ids, addresses = emptySet())),
|
mapOf(userRelay to FavoriteAlgoFeedTopNavPerRelayFilter(ids = ids, addresses = emptySet())),
|
||||||
listenRelays = setOf(dvmRelay),
|
listenRelays = setOf(dvmRelay),
|
||||||
requestIds = setOf(requestId),
|
requestIds = setOf(requestId),
|
||||||
)
|
)
|
||||||
|
|
||||||
val filters = filterHomePostsByDvmIds(set, since = null, defaultSince = null)
|
val filters = filterHomePostsByAlgoFeedIds(set, since = null, defaultSince = null)
|
||||||
|
|
||||||
assertEquals(2, filters.size)
|
assertEquals(2, filters.size)
|
||||||
assertTrue(filters.any { it.relay == userRelay && it.filter.ids != null })
|
assertTrue(filters.any { it.relay == userRelay && it.filter.ids != null })
|
||||||
Reference in New Issue
Block a user