Avoid sending close to subs that are already closed.

This commit is contained in:
Vitor Pamplona
2025-10-02 17:48:06 -04:00
parent c6107dd784
commit 90b682a38f

View File

@@ -231,7 +231,10 @@ class NostrClient(
if (newFilters.isNullOrEmpty()) { if (newFilters.isNullOrEmpty()) {
// some relays are not in this sub anymore. Stop their subscriptions // some relays are not in this sub anymore. Stop their subscriptions
relayPool.close(relay, subId) if (!oldFilters.isNullOrEmpty()) {
// only update if the old filters are not already closed.
relayPool.close(relay, subId)
}
} else if (oldFilters.isNullOrEmpty()) { } else if (oldFilters.isNullOrEmpty()) {
// new relays were added. Start a new sub in them // new relays were added. Start a new sub in them
relayPool.sendRequest(relay, subId, newFilters) relayPool.sendRequest(relay, subId, newFilters)
@@ -267,7 +270,10 @@ class NostrClient(
if (newFilters.isNullOrEmpty()) { if (newFilters.isNullOrEmpty()) {
// some relays are not in this sub anymore. Stop their subscriptions // some relays are not in this sub anymore. Stop their subscriptions
relayPool.close(relay, subId) if (!oldFilters.isNullOrEmpty()) {
// only update if the old filters are not already closed.
relayPool.close(relay, subId)
}
} else if (oldFilters.isNullOrEmpty()) { } else if (oldFilters.isNullOrEmpty()) {
// new relays were added. Start a new sub in them // new relays were added. Start a new sub in them
relayPool.sendCount(relay, subId, newFilters) relayPool.sendCount(relay, subId, newFilters)