Starts NostrClient in active instead of waiting for a connect() call

This commit is contained in:
Vitor Pamplona
2025-10-02 17:47:39 -04:00
parent fd6be80b7e
commit c6107dd784
@@ -43,6 +43,7 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.sample import kotlinx.coroutines.flow.sample
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
/** /**
@@ -85,7 +86,8 @@ class NostrClient(
// controls the state of the client in such a way that if it is active // controls the state of the client in such a way that if it is active
// new filters will be sent to the relays and a potential reconnect can // new filters will be sent to the relays and a potential reconnect can
// be triggered. // be triggered.
private var isActive = false // STARTS active
private var isActive = true
/** /**
* Whatches for any changes in the relay list from subscriptions or outbox * Whatches for any changes in the relay list from subscriptions or outbox
@@ -302,6 +304,7 @@ class NostrClient(
relayList: Set<NormalizedRelayUrl>, relayList: Set<NormalizedRelayUrl>,
) { ) {
eventOutbox.markAsSending(event, relayList) eventOutbox.markAsSending(event, relayList)
if (isActive) { if (isActive) {
relayPool.send(event, relayList) relayPool.send(event, relayList)