mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-26 20:36:23 +02:00
Migrates to a more obvious open/close subscription model for NostrClient
This commit is contained in:
@@ -206,7 +206,7 @@ class NostrClient(
|
||||
return false
|
||||
}
|
||||
|
||||
fun sendRequest(
|
||||
fun openReqSubscription(
|
||||
subId: String = newSubId(),
|
||||
filters: Map<NormalizedRelayUrl, List<Filter>>,
|
||||
) {
|
||||
@@ -239,7 +239,7 @@ class NostrClient(
|
||||
}
|
||||
}
|
||||
|
||||
fun sendCount(
|
||||
fun openCountSubscription(
|
||||
subId: String = newSubId(),
|
||||
filters: Map<NormalizedRelayUrl, List<Filter>>,
|
||||
) {
|
||||
|
@@ -56,7 +56,7 @@ fun NostrClient.downloadFirstEvent(
|
||||
|
||||
subscribe(listener)
|
||||
|
||||
sendRequest(subscriptionId, filters)
|
||||
openReqSubscription(subscriptionId, filters)
|
||||
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
delay(30000)
|
||||
|
@@ -126,14 +126,14 @@ class SubscriptionController(
|
||||
// was active and is not active anymore, just close.
|
||||
client.close(subId)
|
||||
} else {
|
||||
client.sendRequest(subId, updatedFilters)
|
||||
client.openReqSubscription(subId, updatedFilters)
|
||||
}
|
||||
} else {
|
||||
if (updatedFilters == null) {
|
||||
// was not active and is still not active, does nothing
|
||||
} else {
|
||||
// was not active and becomes active, sends the entire filter.
|
||||
client.sendRequest(subId, updatedFilters)
|
||||
client.openReqSubscription(subId, updatedFilters)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user