Improves caching on the allRelays call on the Nostr Client

This commit is contained in:
Vitor Pamplona
2025-07-03 10:30:53 -04:00
parent da3dbb0321
commit 47e69ce045
3 changed files with 3 additions and 8 deletions
@@ -39,7 +39,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.forEach
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
@@ -89,7 +88,7 @@ class NostrClient(
eventOutbox.forEachUnsentEvent(relay, liveRelay::send)
}
fun connectedRelayList() = relayPool.getAll()
fun allAvailableRelays() = relayPool.getAll()
// Reconnects all relays that may have disconnected
fun connect() = relayPool.connect()
@@ -239,7 +238,5 @@ class NostrClient(
fun getSubscriptionFiltersOrNull(subId: String): List<RelayBasedFilter>? = activeSubscriptions.getSubscriptionFiltersOrNull(subId)
fun connectedRelays() = relayPool.connectedRelays()
fun relayStatusFlow() = relayPool.statusFlow
}
@@ -54,7 +54,7 @@ class RelayPool(
fun getRelay(url: NormalizedRelayUrl): IRelayClient? = relays.get(url)
fun getAll() = relays.keys()
fun getAll() = statusFlow.value.connected
fun getAllNeedsToReconnect() = relays.filter { url, relay -> relay.needsToReconnect() }