diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/dto/RelayDTO.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/dto/RelayDTO.kt index aeafc745..c2258242 100644 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/dto/RelayDTO.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/dto/RelayDTO.kt @@ -1,6 +1,7 @@ package ac.cord.auxiliary.compose.network.dto import ac.cord.auxiliary.compose.database.model.Relay +import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.serialization.Serializable @Serializable @@ -9,7 +10,6 @@ data class RelayDTO( val read: Boolean, val write: Boolean, ) { - } fun Relay.mapToRelayDTO() = diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelayPool.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelayPool.kt index 2472c3e6..c686f3cb 100644 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelayPool.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelayPool.kt @@ -117,10 +117,13 @@ class RelayPool( } fun addRelaysIfMissing(relays: Set) { - val existingRelayUrls = socketClients.map { it.socketUrl } + logger.d("addRelaysIfMissing: ${relays.map { it.url }}") + val existingRelayUrls = socketClients.map { NormalizedRelayUrl(it.socketUrl).displayUrl() } + logger.d("Existing Relays: $existingRelayUrls") val newRelayUrls = relays.map { it.url } - val toAddRelayUrls = newRelayUrls.filter { it !in existingRelayUrls }.toSet() + val toAddRelayUrls = newRelayUrls.filter { NormalizedRelayUrl(it).displayUrl() !in existingRelayUrls }.toSet() + logger.d("toAddRelayUrls: $toAddRelayUrls") val toAddSocketClients = relays.filter { it.url in toAddRelayUrls }.mapAsNostrSocketClient() logger.d("toAddSocketClients: ${toAddSocketClients.map { it.socketUrl }}" ) val newSocketClients = socketClients.toMutableSet().apply { diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelaysSocketManager.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelaysSocketManager.kt index ed5ab73e..d772e6cf 100644 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelaysSocketManager.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/relays/RelaysSocketManager.kt @@ -134,7 +134,7 @@ class RelaysSocketManager constructor( } } - suspend fun tryConnectingToUserRelay(url: String) = relayPool.tryConnectingToRelay(url) +// suspend fun tryConnectingToUserRelay(url: String) = relayPool.tryConnectingToRelay(url) suspend fun query(reqCommand: ReqCmd, relayUrl: String): Flow { return relayPool.query( diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/sockets/NostrSocketClientImpl.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/sockets/NostrSocketClientImpl.kt index fd4ffc43..406989f6 100644 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/sockets/NostrSocketClientImpl.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/network/sockets/NostrSocketClientImpl.kt @@ -2,6 +2,8 @@ package ac.cord.auxiliary.compose.network.sockets import ac.cord.auxiliary.compose.exceptions.NetworkException import co.touchlab.kermit.Logger +import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import fr.acinq.lightning.channel.states.Normal import io.ktor.client.HttpClient import io.ktor.client.plugins.websocket.webSocketSession import io.ktor.websocket.CloseReason @@ -61,7 +63,7 @@ internal class NostrSocketClientImpl( wsMutex.withLock { if (wsSession == null || wsSession?.isActive == false) { - wsSession = acquireWebSocketSession(url = socketUrl) + wsSession = acquireWebSocketSession(socketUrl) } } }