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