Shows all users cited in subscriptions for each relay.
This commit is contained in:
+17
-4
@@ -23,8 +23,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.connected
|
|||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.Amethyst
|
import com.vitorpamplona.amethyst.Amethyst
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
|
import com.vitorpamplona.amethyst.model.LocalCache.users
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySetupInfo
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySetupInfo
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySetupInfoModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySetupInfoModel
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
@@ -34,16 +36,27 @@ class ConnectedRelayListViewModel : BasicRelaySetupInfoModel() {
|
|||||||
|
|
||||||
return relayList
|
return relayList
|
||||||
.map {
|
.map {
|
||||||
|
val reqs = Amethyst.instance.client.activeRequests(it)
|
||||||
|
|
||||||
|
val users = mutableSetOf<HexKey>()
|
||||||
|
reqs.forEach { id, filters ->
|
||||||
|
filters.forEach { filter ->
|
||||||
|
filter.authors?.forEach { pubkey ->
|
||||||
|
users.add(pubkey)
|
||||||
|
}
|
||||||
|
filter.tags?.get("p")?.forEach { pubkey ->
|
||||||
|
users.add(pubkey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BasicRelaySetupInfo(
|
BasicRelaySetupInfo(
|
||||||
relay = it,
|
relay = it,
|
||||||
relayStat = Amethyst.instance.relayStats.get(it),
|
relayStat = Amethyst.instance.relayStats.get(it),
|
||||||
forcesTor =
|
forcesTor =
|
||||||
Amethyst.instance.torEvaluatorFlow.flow.value
|
Amethyst.instance.torEvaluatorFlow.flow.value
|
||||||
.useTor(it),
|
.useTor(it),
|
||||||
users =
|
users = users.mapNotNull { hex -> LocalCache.checkGetOrCreateUser(hex) },
|
||||||
account.declaredFollowsPerUsingRelay.value[it]?.mapNotNull { hex ->
|
|
||||||
LocalCache.checkGetOrCreateUser(hex)
|
|
||||||
} ?: emptyList(),
|
|
||||||
)
|
)
|
||||||
}.distinctBy { it.relay }
|
}.distinctBy { it.relay }
|
||||||
.sortedBy { it.relayStat.receivedBytes }
|
.sortedBy { it.relayStat.receivedBytes }
|
||||||
|
|||||||
Reference in New Issue
Block a user