Marks if it is using Tor in each relay of the list.

This commit is contained in:
Vitor Pamplona
2025-07-02 15:15:19 -04:00
parent e499410ddb
commit 3b260d98ad
5 changed files with 36 additions and 10 deletions
@@ -30,10 +30,15 @@ data class BasicRelaySetupInfo(
val relay: NormalizedRelayUrl,
val relayStat: RelayStat,
val paidRelay: Boolean = false,
val forcesTor: Boolean = false,
)
fun relaySetupInfoBuilder(normalized: NormalizedRelayUrl): BasicRelaySetupInfo =
fun relaySetupInfoBuilder(
normalized: NormalizedRelayUrl,
forcesTor: Boolean = false,
): BasicRelaySetupInfo =
BasicRelaySetupInfo(
normalized,
RelayStats.get(normalized),
relay = normalized,
relayStat = RelayStats.get(normalized),
forcesTor = forcesTor,
)
@@ -72,8 +72,8 @@ fun BasicRelaySetupInfoClickableRow(
val iconUrlFromRelayInfoDoc by loadRelayInfo(item.relay, accountViewModel)
RenderRelayIcon(
item.relay.displayUrl(),
iconUrlFromRelayInfoDoc?.icon,
iconUrlFromRelayInfoDoc.id ?: item.relay.displayUrl(),
iconUrlFromRelayInfoDoc.icon,
loadProfilePicture,
loadRobohash,
item.relayStat.pingInMs,
@@ -78,13 +78,18 @@ abstract class BasicRelaySetupInfoModel : ViewModel() {
}
fun clear() {
var hasModified = false
_relays.update {
val relayList = getRelayList() ?: emptyList()
relayList
.map { relaySetupInfoBuilder(it) }
.distinctBy { it.relay }
.map {
relaySetupInfoBuilder(
normalized = it,
forcesTor =
account.torRelayState.flow.value
.useTor(it),
)
}.distinctBy { it.relay }
.sortedBy { it.relayStat.receivedBytes }
.reversed()
}
@@ -36,6 +36,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@@ -72,10 +73,22 @@ fun RelayNameAndRemoveButton(
if (item.paidRelay) {
Icon(
imageVector = Icons.Default.Paid,
null,
contentDescription = stringRes(id = R.string.paid_relay),
modifier =
Modifier
.padding(start = 5.dp, top = 1.dp)
.padding(start = 5.dp)
.size(14.dp),
tint = MaterialTheme.colorScheme.allGoodColor,
)
}
if (item.forcesTor) {
Icon(
painter = painterResource(R.drawable.ic_tor),
contentDescription = stringRes(id = R.string.tor_relay),
modifier =
Modifier
.padding(start = 5.dp)
.size(14.dp),
tint = MaterialTheme.colorScheme.allGoodColor,
)
+3
View File
@@ -244,6 +244,9 @@
<string name="public_chat_relays_explainer">Insert between 13 relays that host this group.
Nostr clients use this setting to know where to download messages from and send your messages to.</string>
<string name="paid_relay">Paid relay</string>
<string name="tor_relay">Forces Tor when connecting</string>
<string name="posts_received">posts received</string>
<string name="remove">Remove</string>
<string name="sats" translatable="false">sats</string>