mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-10 15:42:53 +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
|
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>>,
|
||||||
) {
|
) {
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user