Fixes trusted relay lists incorrectly only using DM relays

This commit is contained in:
Vitor Pamplona
2025-10-06 14:41:56 -04:00
parent 0843d5db95
commit 8c93560058

View File

@@ -52,6 +52,9 @@ class AccountsTorStateConnector(
listOf(MutableStateFlow(emptySet())) listOf(MutableStateFlow(emptySet()))
} }
if (dmFlowReady.isEmpty()) {
emit(emptySet())
} else {
emitAll( emitAll(
combine(dmFlowReady) { combine(dmFlowReady) {
val dmRelays = mutableSetOf<NormalizedRelayUrl>() val dmRelays = mutableSetOf<NormalizedRelayUrl>()
@@ -61,6 +64,7 @@ class AccountsTorStateConnector(
dmRelays.toSet() dmRelays.toSet()
}, },
) )
}
}.onEach { }.onEach {
torEvaluatorFlow.dmRelays.tryEmit(it) torEvaluatorFlow.dmRelays.tryEmit(it)
}.stateIn( }.stateIn(
@@ -74,22 +78,26 @@ class AccountsTorStateConnector(
accountsCache.accounts accountsCache.accounts
.debounce(200) .debounce(200)
.transformLatest { snapshot -> .transformLatest { snapshot ->
val dmFlows = snapshot.map { it.value.dmRelayList.flow } val trustedRelayFlows = snapshot.map { it.value.trustedRelays.flow }
val dmFlowReady = val trustedRelayFlowReady =
dmFlows.ifEmpty { trustedRelayFlows.ifEmpty {
listOf(MutableStateFlow(emptySet())) listOf(MutableStateFlow(emptySet()))
} }
if (trustedRelayFlowReady.isEmpty()) {
emit(emptySet())
} else {
emitAll( emitAll(
combine(dmFlowReady) { combine(trustedRelayFlowReady) {
val dmRelays = mutableSetOf<NormalizedRelayUrl>() val trustedRelays = mutableSetOf<NormalizedRelayUrl>()
it.forEach { it.forEach {
dmRelays.addAll(it) trustedRelays.addAll(it)
} }
dmRelays.toSet() trustedRelays.toSet()
}, },
) )
}
}.onEach { }.onEach {
torEvaluatorFlow.trustedRelays.tryEmit(it) torEvaluatorFlow.trustedRelays.tryEmit(it)
}.stateIn( }.stateIn(