Migrates to a more obvious open/close subscription model for NostrClient

This commit is contained in:
Vitor Pamplona
2025-08-11 10:34:10 -04:00
parent d5b9d5e80b
commit d0f3dde08b
3 changed files with 5 additions and 5 deletions

View File

@@ -206,7 +206,7 @@ class NostrClient(
return false return false
} }
fun sendRequest( fun openReqSubscription(
subId: String = newSubId(), subId: String = newSubId(),
filters: Map<NormalizedRelayUrl, List<Filter>>, filters: Map<NormalizedRelayUrl, List<Filter>>,
) { ) {
@@ -239,7 +239,7 @@ class NostrClient(
} }
} }
fun sendCount( fun openCountSubscription(
subId: String = newSubId(), subId: String = newSubId(),
filters: Map<NormalizedRelayUrl, List<Filter>>, filters: Map<NormalizedRelayUrl, List<Filter>>,
) { ) {

View File

@@ -56,7 +56,7 @@ fun NostrClient.downloadFirstEvent(
subscribe(listener) subscribe(listener)
sendRequest(subscriptionId, filters) openReqSubscription(subscriptionId, filters)
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
delay(30000) delay(30000)

View File

@@ -126,14 +126,14 @@ class SubscriptionController(
// was active and is not active anymore, just close. // was active and is not active anymore, just close.
client.close(subId) client.close(subId)
} else { } else {
client.sendRequest(subId, updatedFilters) client.openReqSubscription(subId, updatedFilters)
} }
} else { } else {
if (updatedFilters == null) { if (updatedFilters == null) {
// was not active and is still not active, does nothing // was not active and is still not active, does nothing
} else { } else {
// was not active and becomes active, sends the entire filter. // was not active and becomes active, sends the entire filter.
client.sendRequest(subId, updatedFilters) client.openReqSubscription(subId, updatedFilters)
} }
} }
} }